0

I am using jqgrid in my project. I need to make it so that when a user selects a row and clicks on the edit button in the inline toolbar control and modifies any data in the cell, after that instead of clicking on the Save button in the inline toolbar control the user goes to the next page of the grid. Then, I want to show the user a message like "Do you want to save/discard the modified data from previous page?" If the user clicks on the Save button of the dialog then it saves the data, otherwise it discards the data. Please let me know how can I implement it.

Pankaj
  • 3,131
  • 4
  • 14
  • 22

1 Answers1

0

You should do almost the same like in the answer on your previous question. You wanted to prevent selection of the row during other row is editing. Thus beforeSelectRow returned false first of all and to then called saveRow or restoreRow following setSelection. In the same way you can use onPaging callback, display the dialog and return "stop" if the grid is editing. After the user will make the choice between saving and discarding the changes you can call saveRow or restoreRow and then call reloadGrid with page parameter (see the old answer).

The information about new page, which chosen the user, can be received from the options of onPaging callback. The options depend on the version of jqGrid, which you use and from the fork of jqGrid, which you use. Free jqGrid for example calls onPaging with two parameters. The first one is described in the old documentation. The second parameter is options object with properties currentPage, newPage, lastPage, currentRowNum and newRowNum. Thus you get all information, which you could need from the options parameter. See the old answer and the wiki article for more details.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • I have tried in the same way as you explained but it's not working.If possible please provide if sample code? so that I implement in same way. – Pankaj Sep 08 '16 at 11:37
  • @Pankaj: Sorry, but I have of cause no demo, which do exactly what you need. If you need some help then you should create the demo (in JSFiddle, for example), which probably not work exactly how you want. I could modify the demo to fix the problem. – Oleg Sep 08 '16 at 11:58
  • I have one sample in JSFiddle (http://fiddle.jshell.net/needhelp18/6zaHp/) you just modify the code and let me know where I'm wrong. – Pankaj Sep 08 '16 at 12:07
  • @Pankaj: The demo do nothing from which I wrote you in my answer. It don't contains even `onPaging` callback and don't use inline editing. You should understand that I have my main job and just try to help other people in stackoverflow. I can't do your job. I just try to help other people. – Oleg Sep 08 '16 at 12:15
  • Sorry I have given you wrong URL.You can try this one http://fiddle.jshell.net/6zaHp/174/ – Pankaj Sep 08 '16 at 12:46
  • @Pankaj: Your demo just contains many errors starting with missing jQuery UI JS. The fixed demo is http://fiddle.jshell.net/OlegKi/6zaHp/175/. `switch (pgButton) {...}` should be extended. I recommend you to changes URLs jqGrid 4.6 to URLs of free jqGrid described [here](https://github.com/free-jqgrid/jqGrid/wiki/Access-free-jqGrid-from-different-CDNs). You will see that the `pgButton` of jqGrid 4.6 contains the bug: the name of the pager id (more old jqGrid versions don't has the problem). I fixed the bug in free jqGrid. – Oleg Sep 08 '16 at 13:47