I have an editable igGrid set up to save pending transactions using RESTful services. Excerpt:
$("#ar_invoices").igGrid({ aggregateTransactions : true, columns : [ blah blah ], features : [ { name : 'Updating', editMode: "row", showDoneCancelButtons : true, columnSettings : [ blah blah ] } ], restSettings: { contentType: "application/x-www-form-urlencoded; charset=UTF-8", contentSerializer: iggridUrlEncode, create: { url: env_constants.DATASERVICES_URL + "/ar_invoices/" }, update: { url: env_constants.DATASERVICES_URL + "/ar_invoices/" }, remove: { url: env_constants.DATASERVICES_URL + "/ar_invoices/" } } });
The issue I'm currently wrestling with is error handling when a batch of changes are submitted. Here is my JavaScript function for saving pending changes:
function ar_invoice_changes_save() { $("#saveResult").text(""); $("#ar_invoices").igGrid("saveChanges", function (data) { $("#user_prompt").text("Changes were saved successfully").fadeIn(3000).fadeOut(5000); }, function (jqXHR, textStatus, errorThrown) { alert(jqXHR.responseText); });}
My question is how to handle errors if the user adds multiple rows and saves them. The grid seems to keep all pendingTransactions around, which makes sense if they are saved in a transaction, but RESTful transactions are submitted independently. For example, consider the following scenario:
This is not a problem for PUT, which is idempotent, and possibly not for DELETE, but POST-ing new rows is explicitly not idempotent.
At a high level, my options seem to be:
Does the grid have any support for #1? For example, knowing which pending transactions succeeded, if any? (Note: I am using "aggregateTransactions : true" so as I understand it, each edited row is effectively one transaction.)
Other suggestions also welcome. Thanks,