Hi,
I'd like to know if it is possible to manage the result that controller action send bakc after a "saveChanges" igGrid called method.
My controller action ends with:
JsonResult result = new JsonResult(); Dictionary<string, bool> response = new Dictionary<string, bool>(); response.Add("Success", true); result.Data = response; return result;
And I know that, if ("Success", true) everything goes right. But if I would like to have more info, or just catch ("Success", false), is there a way to get result in javascript section? Now I have (for example related to deleted row event):
$("#grid1").live('iggridupdatingrowdeleted', function (event, ui) { $("#grid1").igGrid("saveChanges"); });
If I put:
result = $("#grid1").igGrid("saveChanges");
I can see that result is a HTMLTableElement object...is it right? Do you have some suggestions to let me understand how manage saveChanges result or just to manage a negative come back result?Thank you,
Flavio
This was a sample of my code with a MVC view. The m is the Model instance in a foreach loop - foreach(var m in Model)
<script type="text/javascript"> $(function () { //function that handles the result after the updates $("#Grid_@m.QuotaID").data("igGrid").dataSource._addChangesSuccessHandler(function (data, textStatus, jqXHR) { alert("Request status: " + textStatus); }); }); </script> <script type="text/javascript"> $(function () { //function that handles the result after the updates $("#Grid_@m.QuotaID").data("igGrid").dataSource._addChangesErrorHandler(function (data, textStatus, jqXHR) { alert("Request FAILURE status: " + textStatus); }); }); </script>
Hello - I believe I had the same confusion about this and how to handle the FAILUREs. I would point out that there is the ability to handle the Failure message with a 2nd function when calling the saveChanges method.. See the documentation screenshot
I can answer my own question.
I had this in my code:
$("#TimesheetGrid").data("igGrid").dataSource._addChangesSuccessHandler(changesSuccessHandler);$("#TimesheetGrid").igHierarcichicalGrid("saveChanges");
which doesn't work. It did save the changes but didn't fire changesSuccessHandler.
I tried this:$("#TimesheetGrid").data("igHierarcichicalGrid").dataSource._addChangesSuccessHandler(changesSuccessHandler);$("#TimesheetGrid").igHierarcichicalGrid("saveChanges");
which didn't work either - didn't even save the changes.
I then changed the saveChanges to reference via igGrid instead of igHierarchicalGrid and it worked fine - data saved and changesSuccessHandler called:
$("#TimesheetGrid").data("igGrid").dataSource._addChangesSuccessHandler(changesSuccessHandler);$("#TimesheetGrid").igGrid("saveChanges");
Sometimes just asking the question presents the answer.
Graeme
Hi
Should this work OK with an igHierarchicalGrid?
I have got it working fine for a normal igGrid but when I use the same technique with a hierarchical grid my equivalent of the "test" function never gets called.
eg this works on my invoice page with igGrid and the function named "changesSuccessHandler" is called:
$("#InvoiceGrid").data("igGrid").dataSource._addChangesSuccessHandler(changesSuccessHandler);
this does not work on my timesheet page with a igHierarchicalGrid - "changesSuccessHandler" is never called:
$("#TimesheetGrid").data("igGrid").dataSource._addChangesSuccessHandler(changesSuccessHandler);
Regards,
Hi Flavio,
change this:
$("#myGrid").data("igGrid").dataSource._addChangesSuccessHandler( test() );
to this:
$("#myGrid").data("igGrid").dataSource._addChangesSuccessHandler( test);
the handler shouldn't be a function invocation like test(), but the actual reference itself , that is "test" itself - without the quotes.
Hope it helps
Angel