StrataFrame Forum

Deleting multiple rows with one confirmation

http://forum.strataframe.net/Topic8752.aspx

By Peter Jones - 5/12/2007

Hi,

If I select 5 rows in a grid (Devexpress) for deletion and hit delete StrataFrame asks me to confirm the delete of each row one at a time. Can I change this to delete all 5 in one hit?

Actually, the ideal would be to be able to select either confirm one at time or all at once at the BO level.

Cheers, Peter

By StrataFrame Team - 5/14/2007

The problem is that the grid deletes each record individually, which calls DeleteCurrentRow() on the business object for each record that needs to be deleted.  What you'll need to do is turn off the AutoShowDeleteConfirmation and handle the delete event on the grid to show your own message.
By Peter Jones - 5/14/2007

Hi Ben,

Thanks for that. One (hopefully) minor issue remains - in the BO's BeforeDelete I want to display a message along the lines: "Confirm deletion of X rows". However I just can't find a BO Data Table or Data View property that tells me if a row is selected or not so I can calculate a value for X. Obviously it must be available for physical deletion process but I just can't identify where it is.

Cheers, Peter

By Trent L. Taylor - 5/15/2007

There is only one indicator for a row selection in the BO and that is the CurrentRowIndex which is displayed in the CurrentRow.  This logic is left up to you as to know which rows are to be deleted.  If they are loaded into a List then you could delete all of the rows by PK which have been selected in the list.  There is nothing in the BO that allows you to "select." Now you can navigate through a BO and "mark: it for deletion back on the server without actually deleting until you call Save().  This is done by calling the DeleteCurrentRow(True) on the BO.
By Peter Jones - 5/15/2007

Hi Trent,

Thanks for that. Just to bring this thread up to date here's what I did:

1) Intercepted the delete button press on the (DevExpress) grid.

2) Checked if the BO's AutoShowDeleteConfirmation is False.

3) Is so fired my delete confirmation message and used the grid's SelectedRowsCount for delete record count.

4) If the user says ok to the delete then process as normal otherwise I cancel the button press event.

Cheers, Peter

By Trent L. Taylor - 5/16/2007

Glad to hear you got it working Smile