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
135
How to get the list of deleted rows in a WinGrid?
posted

Hello,

 

I have an ultragrid with 2 buttons: Add and Delete.

When the user clicks the Delete button, I invoke the ultraGrid.DeleteSelectedRows() method.

 

Now, I want to get the list of deleted rows (particularly, I need the ListObjects of the rows) after they are successfully removed.

Unfortunately, the ultraGrid.DeleteSelectedRows() does not return the list of rows that have been successfully removed.

As a workaround, I am building a temporary list of items to be removed using the BeforeDeletedRows event and I use the AfterDeletedRows to persist the temporary list to the effective list of objects that were removed.

 

Is there a simpler way to get it?

 

Thank you.

Best Regards,

  Pedro Rosas

  • 37774
    Verified Answer
    posted

    Pedro,

    The grid does not maintain any of the deleted rows, the same as it doesn't maintain a list of rows that have been modified; this is the job of the DataSource that the grid is bound to.  When the grid deletes a row, it tells the BindingManager to remove the ListObject from the collection and then will destroy the UIElement (and row object) when it is next painted, since there is no corresponding row.  It seems like the way that you're doing it now is the best way of accomplishing this if your DataSource does not support a different method of tracking this.  If you have control over your DataSource (i.e. it's a custom implementation), you might be able to keep track of these through the implementaion of RemoveAt(index), or other 'delete' functions.

    -Matt