persist - jqGrid applying sort from known values not working -
i have jqgrid , want apply user's sort values after loads. these values saved , retrieved in jquery cookies. storing data in cookies because user go url , come initiates page load , want in same spot left.
i have loadpreferences function being called within loadcomplete. see code snippet below(i left several jqrid properties out keep posting short).
// set jquery grid $("#jqgridtable").jqgrid( { // ajax related configurations url: jqdataurl, datatype: "json", mtype: "get", autowidth: true, // configure columns colmodel: columnmodels, // grid total width , height height: "100%", // customize jqgrid post init gridcomplete: function() { cref.updatejqgridpagericons("jqgridtable"); }, // default sorting sortname: "lastname", sortorder: "asc", sorttype: "text", sortable: true, jsonreader: { root: "rows", page: "page", total: "total", records: "records", repeatitems: false, userdata: "userdata" }, loadcomplete: function (data) { if (boolpreferencesloaded == false)//page level variable { boolpreferencesloaded = loadpreferences(this); $("#jqgridtable").trigger("reloadgrid"); } isgridsorting(this, false); } ...the rest of grid properties...
and in function call(which located in js file), have...
function loadpreferences(gridid) { if (typeof $.cookie("sortcol") !== "undefined") { $(gridid).jqgrid("sortgrid", $.cookie("sortcol"), true, $.cookie("sortord")); } return true; } function isgridsorting(gridid, sorting) { $.cookie("sortcol", $(gridid).jqgrid('getgridparam', 'sortname')); $.cookie("sortord", $(gridid).jqgrid('getgridparam', 'sortorder')); $(gridid).jqgrid('setgridparam', { postdata: { issorting: sorting } }); }
my problem when go apply them on page load(with jqgrid specified above), not work. icon moves correct column , arrow pointing in correct direction, data in column not sort.
i know there lot of posts dealing similar issues, not able solutions work. trying seems easy, it's driving me nuts. if respond, please make comment easy understand. thank you.
Comments
Post a Comment