views:

29

answers:

1

We use the jqGrid navigator reload button on a grid with loadonce set to true.

The reload button currently does NOT go back to the server to get the data - how can we get the reload to go to the server to get the latest data?

I believe we can use the beforeRefresh callback to set the grid data to json instead of local but I'm not clear how to even configure the beforeRefresh method - I don't really understand the docs.

+1  A: 

You are not the only person which has the problem. I answerd to the same question before. To reload the grid content from the server you should reset the datatype parameter to original value "json" or "xml" and then refresh the grid. For example

jQuery("#list").jqGrid('setGridParam',{datatype:'json'}).trigger('reloadGrid');

UPDATED: To call the line inside of beforeRefresh event handler you can do following

jQuery("#list").jqGrid('navGrid','#pager',
  { edit:false,view:false,add:false,del:false,search:false,
    beforeRefresh: function(){
        alert('In beforeRefresh');
        grid.jqGrid('setGridParam',{datatype:'json'}).trigger('reloadGrid');
    }
  });

I modified an example from am old question. Here if you click on the refresh button you can see live how the code work.

Oleg
Thanks - How can you run this code when the reload button is clicked? I am not clear how to configure the nav bar to execute the `beforeRefresh` method if this is what you are alluding to.
Marcus
@Marcus: If is very easy. I includes the corresponding code in my answer.
Oleg