Reputation: 11946
In a page, I have a form and a JQGrid. The form is used to enter specific filters. So the Javascript for that page contains a function which reloads the data in order to populate the JQGrid. The JQGrid has loadonce: true
, so the refresh button doesn't do anything. I would need to make it call my existing function. Is it possible ?
Upvotes: 1
Views: 330
Reputation:
A simple enough fix:
loadonce: false
really, setting this to true will serve no other purpose that you have specified.
Upvotes: 1
Reputation: 221997
If I understand you correctly then your problem exist because loadonce: true
option changes the original datatype
("json"
or "xml"
) to "local"
. It allows to use local paging, sorting and filtering of data. During the paging, filtering and sorting the grid will be reloaded, so local reloading do have sense.
If you need to reload the grid from the server you should first restore the original value of datatype
and then do reloading.
So if you can use beforeRefresh
callback of navGrid
to reset datatype
:
$("#grid").jqGrid("navGrid", "#pager", {
beforeRefresh: function () {
$(this).jqGrid("setGridParam", {datatype: "json"});
}
});
If you use free jqGrid then you can use new fromServer: true
option of reloadGrid
and you can use new style of options and new reloadGridOptions
option of navGrid
. The code will be like
$("#grid").jqGrid({
// standard jqGrid options
navOptions: {
// default options of navGrid
reloadGridOptions: {fromServer: true}
}
}).jqGrid("navGrid");
It will work with datatype:"json"
or datatype:"xml"
.
Upvotes: 2