2

I am updating a column value in jqgrid. After update i want to reload the grid and maintain page number with the updated data. For ex. if I am updating value in page 2. I want to reload the jggrid with updated value and page 2. I am using this code for reloading the grid.

function reload(){
   $("#table1").setGridParam({
    datatype : 'json',
    page : 1
}).trigger('reloadGrid');    
}

But it is reloading the grid with page 1.

I tried using

$("#table1").trigger("reloadGrid", [{current:true}]);

But it is not working. Please provide a solution.

Ann
  • 45
  • 1
  • 3
  • 14

2 Answers2

1

You should use page property of the options of reloadGrid:

$("#table1").trigger("reloadGrid", [{current:true, page:2}]);

see the old answer.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • it is maintaining page number 2 but not refreshing updated data into the grid It is not hitting server to populate the data. – Ann Jul 31 '14 at 13:41
  • @Neha: Probably you have *another* problem. If you use `loadonce: true` option then `datatype` will be changed from the initial value (`"json"` or `"xml"`) to `"local"`. So to reload the data *from the server* you have to use `$("#table1").jqGrid("setGridParam", {datatype: "json"}).trigger("reloadGrid", [{current: true, page: 2}]):` – Oleg Jul 31 '14 at 13:55
  • I just posted a question here: http://bit.ly/1uCH1cz basically asking the same question, but this approach did not work for me, any idea what I might be missing? – Tone Sep 05 '14 at 04:29
  • 1
    @Tone: I don't think that it's the same problem. You want **don't reload the grid**. So no options of `reloadGrid` can solve the problem. – Oleg Sep 05 '14 at 06:30
0

You could get the page grid parameter and use it to tell the reload which page you would like to navigate to when the reload is complete.

function reload(){
   var page = $("#table1").getGridParam("page");    //Add this

   $("#table1").setGridParam({
       datatype : 'json',
       page : page            //Replace the '1' here
    }).trigger('reloadGrid');    
}
LucidDemon
  • 21
  • 1