I am implementing a RadGrid with batch mode editing using clientside binding with a RadClientDataSource. I am finding that calling .hasChanges() results in records flagged for Delete to not actually get deleted when .saveChanges() executes.
This is my setup:
I created my own button for saving, as such:
<
CommandItemTemplate
>
<
telerik:RadButton
ID
=
"RadButtonSave"
runat
=
"server"
Text
=
"Save"
CssClass
=
"GoButton"
AutoPostBack
=
"false"
OnClientClicked
=
"function(){ saveChanges();}"
>
</
telerik:RadButton
>
</
CommandItemTemplate
>
Which calls the following javascript function:
function saveChanges() {
var grid = $find("<%= RadGrid1.ClientID %>");
//var isDirty = grid.get_batchEditingManager().hasChanges(grid.get_masterTableView());
grid.get_batchEditingManager().saveChanges(grid.get_masterTableView());
}
If I make changes to grid data and click the Save button the webservices for the insert, update, delete are being called.
HOWEVER, if I uncomment the "var isDirty...." line in the above .saveChanges() function that calls .hasChanges(), then the Deletes will no longer save. The web service for deletes simply does not get called. Inserts and update still work correctly. If i comment out that line, then the deletes work again.
I found the same behaviour on a LiveDemo example that checks .hasChanges().
https://demos.telerik.com/aspnet-ajax/grid/examples/data-binding/client-side/client-data-source-binding/defaultcs.aspx
Steps to reproduce:
- Make any change to the first record, such as modifying the Contact Name.
- On the second record, Click the "x" under the DELETE column to mark it for delete.
- Click any column heading to sort. (This calls a UserAction event handler that calls .hasChanges())
- Choose to Cancel at the popup prompt.
- Click "Save changes".
- Monitor the browser console, you will find that webservice UpdateCustomers is called, but DeleteCustomers is not.
Please confirm whether this is a bug and if there is a workaround.