I have a grid that does the batch update by doing $('#grid').igGrid('saveChanges'). In my controller that handles the save, I followed the sample code to return JsonResult whether it succeed or fail.
Is there an event that the grid dispatch once the save completed ? if so, how do I access that json result status ? I want to do some more logic once the save is done only when the save finished successfully.
Hi Jeffrey,I'm afraid that there is no public API function available for this operation.However, there's an internal method of the igDataSource that you can use without any problems: _addChangesSuccessHandler.Here's an example of how to get the status of the request after it has arrived:
<script type="text/javascript"> $(function () { $("#Grid1").live("iggridrendered", function (evt, ui) { $("#Grid1").data("igGrid").dataSource._addChangesSuccessHandler(function (data, textStatus, jqXHR) { alert("Request status: " + textStatus); }); }); }); </script>
I'm also attaching an MVC3 sample demo'ing the solution.Cheers,Borislav
Borislav,
One follow up question, what is the difference between doing this: $("#Grid1").data("igGrid").dataSource
and this: $('#Grid1').igGrid('option', 'dataSource')
Seems like the first one works better, as I find the second code doesn't always return me the dataSource object.
Thanks for the quick reply. Tried it just now, and it works perfectly.
Thanks,
Jeffrey
Hello jAndika,
Follow the suggested by Borislav approach and let us know if it works in your scenario.