1

I have a jqGrid in which when I click on the next/previous page, I want to execute some custom function (which saves the uncommitted changes done using inline editing) and once that function finishes execution, I want the default action of onPaging event to execute (i.e. load next page data).

onPaging: function (pgButton) {
    clickedSaveAll = false;
    BulkSave();
}

Actual output : The default action triggers before the custom function.
Please help.

eranjali08
  • 77
  • 10
  • why not save the rows after the user edit? ref @Oleg answer http://stackoverflow.com/a/5943297/330606 –  Jul 15 '15 at 13:17
  • @PauloDiogo Thanks for your reply. This is a client requirement as they are using jqGrid as a person would use excel workbook (I know that sounds weird.) So any help on how to achieve the give problem statement. – eranjali08 Jul 16 '15 at 03:28
  • save the row on server side when the user leave each row. –  Jul 16 '15 at 14:08

1 Answers1

1

It's not full clear what you do inside of BulkSave. It's important to understand that onPaging callback should work synchronously. If you need to make some asynchronous Ajax call to the server for example that you can do the following:

  1. you can analyse pgButton value to calculate which page will be loaded as "default action" of paging.
  2. you can use return "stop"; as the last statement of onPaging callback. It prevents default actions.
  3. you can include .trigger("reloadGrid", {page: savedPage}); at the end of your custom action BulkSave. It will simulates "default action" of paging after your custom action will be finished.
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • thank you for your reply. This solution works perfectly for me. Sorry for the delayed reply as I was away for sometime. I just wanted to know if we an do something to stop the refresh event as well? Also I want to the same thing for Edit option as well. Please help. – eranjali08 Jul 31 '15 at 04:15
  • Thanks once again. For reload button... I have removed the jqGrid default and replaced it with custom button. – eranjali08 Aug 01 '15 at 06:16