I am using cookies to load a users previous sorting and paging options. I would like to take those saved values, and set them as the parameters the server receives.
The paramaters I wish to change are as follows, (rows are replaced by max via prmNames)
/&max=20&page=1&sidx=&sord=asc
I have tried using:
$.extend($.jgrid.defaults, {
sidx:"fName",
sord:"desc",
page:2,
rows:10});
and variations of:
beforeRequest:function(){
$('#grid').jqGrid('setGridParam', {
sidx: "fName",
sord: "desc",
page: 2,
max: 10
});
}
It changes the value for page using $.extend($.jgrid.defaults… , but I cannot get the other parameters to change.
You need just use
setGridParamto set parameters of jqGrid which have another names assidx,sord,pageandrows.So the best would be to create jqGrid directly with the above parameters initialized from the cookie.
If you would have problem with creation the grid directly with the parameters which you need you can first create the grid with
datatype: 'local'which will prevent the loading the grid. Then you change the parameters which you need and additionally setdatatypeto the value which you need (‘json’ or ‘xml’). At the end you reload the grid. So the code should be like the followingIf you would have problem with creation the grid directly with the parameters which you need. additionally create the grid with
datatype: 'local'it will prevent the loading the grid