New row cancell problem with Infragistics UltraGrid

New row cancell problem with Infragistics UltraGrid

Old forum URL: forums.lhotka.net/forums/t/4160.aspx


cslafish posted on Friday, January 11, 2008

I'm using a ultragrid binding to a child businesslist. Since I used a factory method in the parent class to create new item and the default constructor is private so I have to overwrite the grid's BeforeRowInsert event in which I call the factory method to create a new item then invoke e.calcel = true.

The problem is if there exists row(s) in the grid, everything is fine, but if there's no row in the grid, if I click the bottom row to insert a new row, then click off it, it's not removed.

Anyone any point will be appreciated.

 

Dawn replied on Saturday, January 12, 2008

Hi cslafish,

Forgive me not understand you clearly.

1. If you want the UltraGrid to allow add new row, you can override child businesslist 's AddNewCore method, and in the child businesslist's constructor set AllowNew to true, then set the UltraGrid.Displayout.Override.AllowAddNew to corrsponding value.

2. If you want to cancel the new row, just press ESCAPE twice, the the UltraGrid will call the business child's CancelEdit, which will remove it from it's parent collection. But I found it work on CSLA 2.0.3.  For CSLA 3.0.2 it's doen't .  And this is what  I want to ask Rocky:

In CSLA 2.0.3, when the grid call BusinessBase's IEditableObject.BeginEdit(), will incur the CopyState call(), the below line will cascade the call to child business list object:

// this is a child object, cascade the call
 ((Core.IUndoableObject)value).CopyState();

but in 3.0.2, it's change to

// this is a child object, cascade the call
 if (!_bindingEdit)
     ((Core.IUndoableObject)value).CopyState(this.EditLevel + 1);

And in BusinessBase's
IEditableObject.BeginEdit(), you have set
    if (!_disableIEditableObject && !BindingEdit)
      {
        BindingEdit = true;
        BeginEdit();
      }

this means the child's CopyState will not called when Control call the BO's IEditableObject.BeginEdit(),   so, Rocky, why if not bindingEdit, then get child's
CopyState call?

Thanks.


Dawn replied on Saturday, January 12, 2008

Find a solution to last post.

I found when the BO's IEditableObject.CancelEdit called, which will finally get BindableBase's OnUnknownPropertyChanged get called, the 3.0.2 implemention of this methods is :

OnPropertyChanged(string.Empty);

which case UltraGrid to call the child object' IEditableObject.BeginEdit, so the child's EditLevel back to origion,  it's doesn't remove it self from the parent collection.  But in 2.0.3 the implement is :

PropertyInfo[] properties =
            GetType().GetProperties(
            BindingFlags.Public | BindingFlags.Instance);
            foreach (PropertyInfo item in properties)
                OnPropertyChanged(item.Name);


this doesn't  incur the IEditableObject.BeginEdit. So,  which I can do is Drive from 3.02  BusinessBase, override it's
OnUnknownPropertyChanged.  I'm using Infragistics V6.3.
Good luck.

cslafish replied on Saturday, January 12, 2008

Hi Dwan, thank you for the reply, I didn't use the way of overwriting AddNewCore method of BusinessList because we have to call the factory method of its parent BusinessObj to create new child since some properies of child are calculated by parent's propertis. That's why I catch BeforeRowInsert event of UltraGrid. And also pressing 'ESC' twice doesn't work since usually the scenario is when user view the form, if he clicks the bottom row by mistake and then click off that row, the new row should be removed, should not force user to press 'ESC' to cancel since he's not intent to create a new row.

The problem now is when there's at least 1 row in the grid, everything works fine, click the bottom and then click on any other place, the row can be removed automatically, but if there's no row in it, click to add new row then click off, that new row won't be cancelled. Wondering if anybody used BeforeRowInsert event before.

 

Dawn replied on Saturday, January 12, 2008

Hi, Cslafish
which i mentioned can cancel the new row automatically if you just click other place.  I think this is more uniform methods. Beacuse even the child need it's parent to create it , you can cache the Parent  in BusinessList when it's get created, so overrides the businessList's AddNewCore, you'll get the information about parent, you don't blending business logic to UI.  press 'ESC' twice apply to the newly added row even is modified by user in UltraGrid, othrewise you click other place it's will cancel it automatically.

Hope this help.

ajj3085 replied on Monday, January 14, 2008

Well the whole idea behind overriding AddNewCore is so that you can create the object via its factory method.  I would try doing that, and not doing the BeforeRowInitialize, or whatrever you're doing now.

cslafish replied on Monday, January 14, 2008

Likely BeforeRowInsert is problematic, I'll do AddNewCore. Thank you guys.

Copyright (c) Marimer LLC