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
705
UltraGridAction.DeleteRows --> how to determine user action and also deleted row information
posted

I have a C# winforms app that in the ultraToolbarManager click event fires the following code when the user clicks the DELETE button in the toolbar:

myGrid.PerformAction(UltraGridAction.DeleteRows);

This works fine for most scenarios.  Now though, I have some child records that need to be deleted as well.  In order to delete these child records through a custom routine, I need to pull a key value from one of the columns of each deleted row (you can delete multiple rows at once in the grid).

First, I need to know if the user deleted the records or if they canceled.  Is there a way through code to do this or do I have to have logic in the AfterRowsDeleted event to account for this?

Second, how do you determine what rows were deleted?

 

Parents
No Data
Reply
  • 130
    posted

    Ok, one approach would be to handle the UltraGrid.BeforeRowsDeleted event.

    What i usually do in such an scenario would be to replace the build in delete dialog, thus i have information what the user finally decided. (As i have row information at that time i just show an modal dialog at the start of the event including some extended info about what the user actually wants to delete).

    Then, depending on the modal dialog return, i either cancle the event or i handle my data stuff like deleting child rows first, maintaining integrity, logs and such. As the data is still fully available at that point, the rows are not yet actually deleted but i know that the user wants to delete them i have full freedom. Usually i cancle the event anyway in the end, and take care of of deleting or mark the "main rows" as deleted in the datasource myself and let the grid just sync.

Children
No Data