Hi,
I have a grid in which I'm overriding the primary key generated by grid using generatePrimaryKeyValue event. I'm setting the value to 0, as my business logic will take care of generating the new primary key.
I have aggregate transactions set to true .
If I add two new rows and then delete the second one and finally commit the changes, the second row is getting saved and first one is deleted.
I believe this is happening because the aggregation works on primary key and both my rows had primary key as 0.
Is there any way to get around this ?
Sushma,
Which grid on which platform are you using?
Im using Infragistics IgGrid in my web application [mvc]
Hello Sushma,
Thank you for posting in our community.
Your assumption is correct. When you commit the changes the row transactions depend on the unique row id. This is the reason why the firs time it meets a row with an ID of 0 it deletes it and it does not proceed further.
What I can suggest for achieving this scenario is getting the pending transaction using pendingTransactions method of igGrid in order to modify the transaction instead of the record itself. This method returns a list of all transaction objects that are pending to be committed. After committing the transaction and before sending them to the server you could modify this collection and set the Id`s to your required values. Afterwards call saveChanges method to send the changes on the server, respectively the modified transactions collection. Afterwards, you could modify it as per your requirement. For example:
$("#saveChanges").click(function () { var pendingTrans = $("#gridUpdating").igGrid("pendingTransactions"); $("#gridUpdating").igGrid("commit"); for (i = 0; i < pendingTrans.length; i++) { pendingTrans[i].rowId = 0; } $("#gridUpdating").igGrid("saveChanges"); });
$("#saveChanges").click(function () {
var pendingTrans = $("#gridUpdating").igGrid("pendingTransactions"); $("#gridUpdating").igGrid("commit"); for (i = 0; i < pendingTrans.length; i++) { pendingTrans[i].rowId = 0; } $("#gridUpdating").igGrid("saveChanges");
});
I hope you will find my suggestion helpful.
Please let me know if you need any further assistance with this matter.