Forum


19:34

12/08/2011

I have been struggling with this all day. My requirement is very simple: I'm using single field searching. I want to save the state of the grid (using postData and a cookie) when I leave the page and restore it when I come back. I'm able to save the postData to a cookie, but can't figure out how to restore the grid state again.
function documentReady()
{
$("#grid_clients").jqGrid({
datatype: "local",
height: 200,
width: 832,
shrinkToFit: true,
caption:"Clients",
colNames :["","Id","Name","Description","Active<br />Studies"],
colModel :[
{name:"edit", index:"edit", width:20, align:"center", sortable:false, search: false},
{name:"id", index:"id", width:40, align:"right", sorttype:'int'},
{name:"name", index:"name", width:200},
{name:"description", index:"description", width:200},
{name:"studycount", index:"studycount", width:50, align:"right", sorttype:'int'}
],
pager:"pager_clients",
scroll: 1,
viewrecords:true,
sortable:true,
sortname: "name",
autowidth: true,
pgbuttons: false,
loadonce: true,
gridview: true
});
$("#grid_clients").jqGrid("navGrid", "#pager_clients",{add:false, edit:false, del:false});
$('#grid_clients').jqGrid('setGridParam', {datatype: 'xml'});
var gridUrl = 'getgridxmlclients.php';
$('#grid_clients').jqGrid('setGridParam', {url: gridUrl});
// If the cookie exists, set the postData and search parameters.
if ($.cookies.get('gridPostData'))
{
alert(dump($.cookies.get('gridPostData')));
$('#grid_clients').jqGrid('setGridParam', {search: true, 'postData': $.cookies.get('gridPostData')});
}
$('#grid_clients').trigger('reloadGrid', [{page:1}]);
}
The alert for the cookie looks like this:
'_search' => "true"
'nd' => "1313100751399″
'rows' => "20″
'page' => "1″
'sidx' => "id"
'sord' => "asc"
'searchField' => "studycount"
'searchString' => "1″
'searchOper' => "eq"
'filters' => ""
The interesting thing is that the parameters seem to have taken, because if I just click on a header to sort the grid, the filter immediately takes affect then. I'm missing the method of forcing the filtering when loading.
Thanks, –David
Most Users Ever Online: 715
Currently Online:
92 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66