Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
250
Keeping a row in EditMode even after you select another row...
posted

I am using the CSLA framework and I have a collection bound to the grid.

The framework support n-level undo.

 So I have a BusinessList<Person> that implement IEditableCollection.

After each edit i call the method that take a snapshot of my object using the following event of the grid :

  private void MasterGrid_BeforeCellUpdate(object sender, BeforeCellUpdateEventArgs e)
        {
            IEditableObject editableBusinessObject = (IEditableObject) e.Cell.Row.ListObject;
            editableBusinessObject.BeginEdit();
        }

I have a button in a cell of each row that should allow the user to "undo" any changes made to that row here is the code :

 private static void UndoRow(UltraGridRow row)
        {
            IEditableObject editableBusinessObject = (IEditableObject) row.ListObject;
            editableBusinessObject.CancelEdit();
            row.Refresh(RefreshRow.ReloadData);
        }

This works fine as long as I stay on the row that is being edited... Meaning as soon as I click another row the ultragrid seems to be calling CommitEdit() on the row that just lost focus (and remove my snapshot at the same time) . This is not the desirable behavior in my case.

Is there a workaround around this ? I've tried different settings put nothing works.

Thanks.

 

Parents
No Data
Reply
  • 469350
    Offline posted

    The grid doesn't call CommitEnd. What happens is that, by default, the grid stays in synch with the current position of the DotNet CurrencyManager. So when you click on another row in the grid, the grid's ActiveRow changes and it updates the current Position of the CurrencyManager. The CurrencyManager calls EndCurrentEdit at this point, which is presumably what causes your changes to be comitted. 

    There's no way that I know of to stop the CurrencyManager from doing this, but you might be able to work around the issue by setting SyncWithCurrencyManager on the grid to false. This will prevent the grid from synchronizing it's ActiveRow with the current Position of the CurrencyManager. Of course, there may be other reasons why the position will change, so I can't promise this will work, but it's probably worth a try. 

Children
No Data