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
300
Batch Update - Deleting mutliple rows fails when SummaryRow behaviour exists
posted

Hi All

We have a problem with our WebDataGrids where we are using Summary Rows.  We have BatchUpdating="True" and if the user deletes multiple rows before pressing save we get the following error;

Requested record cannot be found by key.
Common Causes:
- The data key field(s) is being edited causing the record not to be found when trying to update.
- Not rebinding the grid when there are updates to be committed (assuming DataViewState is disabled in this case) – for instance if the grid is bound on !IsPostback.
- While a user is editing a particular row in the grid, another user deletes the record from the database. On posting back, the grid is rebound to the updated datasource which no longer contains the record, resulting in the exception.
- Changing completely or filtering the grid’s datasource before all CRUD operations are carried out – this is quite common when using other controls on the page to do this . This is partly due to the fact that control events such as SelectedIndexChanged for a dropdownlist or Click for a button fire before the updating events. Changing the grid’s source should in such cases be delayed for later (PreRender).

This problem can be solved by simply removing the SummaryRow behaviour from the grid, but we would prefer to leave it there.

I've reproduced this in a sample project and sent it to IG support - but has anyone come across this and (hopefully) come up with a workaround?

Thanks

Marcus

  • 17590
    Offline posted

    Hello Marcus,

    Thank you for posting in our community.

    By design batch updating is compatible with Summaries. When a row is modified, the columns summaries are immediately affected and recalculated on the client without performing a postback to the server. However, there is only one special case in which it is not possible to recalculate summary on the client. This can happen if data required for calculating is not(or might be) available on the client.

    For example, when user delete a row that contains either a minimum or maximum value or just edit a cell containing such value, then the new minimum/maximum should be calculated. But If the new minimum/maximum value is not available on the client or if you are not whether it is available and cannot check this, you can not retrieve the new minimum/maximum. I believe this is the reason for this exception being thrown.

    In such cases, a special event, called “SummaryRowClientEvents-CalculateSummary”, is fired. It can be handled by you, as the developer, and you can decide, for example, to set a new value or make some modifications to the event arguments and then force a postback and accept the changes. You can also revert the deleted changes on the client side and make no postbacks. If you leave this event unhandled, then automatic postback is called internally and the new extreme value is calculated automatically.

    For other summary values like Count, Average, and Sum, all recalculations take place on the client.

     

    A sample demonstrating how batch updating works in conjunction with summaries could be found at:

    http://es.infragistics.com/products/aspnet/sample/data-grid/batch-updating-summaries

    Additionally, some further reference regarding batch updating behavior of WebDataGrid could be found at:

    http://help.infragistics.com/doc/ASPNET/2013.2/CLR4.0/?page=WebDataGrid_Batch_Updating_Summaries.html

    I hope you find this information helpful.

    Please let me know if you have any further questions regarding this matter.