Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change sidx,sord,filters parameters names in jqGrid

Tags:

jqgrid

If column names are sidx,sord,filters , jqGrid getting data is broken. I tried to add underscores to them using code below but those parameters are still passed without underscores. Other parameters like _rowid, _page etc. are passed properly with underscores.

How to use sidx,sord,filters as column names in jqgrid ?

jQuery.extend(jQuery.jgrid.defaults, {
    prmNames: { id: "_rowid", oper: "_oper", page: "_page",
        sidx: "_sidx", sord: "_sord", page: "_page", rows: "_rows", filters: "_filters"
    }
});
like image 313
Andrus Avatar asked Aug 13 '11 11:08

Andrus


1 Answers

I don't understand what you mean under "If column names are sidx,sord,filters , jqGrid getting data is broken". Nevertheless if you need you can rename or remove the jqGrid parameters with two ways: prmNames and serializeGridData.

You should carefully examine the list of default values of the prmNames. There are no possibility to rename filters in the way, but to rename the name of other parameters you should use

$.extend(jQuery.jgrid.defaults, {
    prmNames: {
        id: "_rowid", page: "_page", rows: "_rows",
        oper: "_oper", sort: "_sidx", order: "_sord"
    }
});

(sort and order instead of sidx and sord). To rename filters to _filters and to remove sending of empty searchField, searchString and searchOper you can do almost the same what I described here:

serializeGridData: function (postData) {
    var myPostData = $.extend({}, postData); // make a copy of the input parameter
    myPostData._filters = myPostData.filters;
    delete myPostData.filters;
    delete myPostData.searchField;
    delete myPostData.searchString;
    delete myPostData.searchOper;
    return myPostData;
}

Using Fiddler or Firebug you can verify that in the URL of the demo are used the following parameters

_search=true&nd=1313235583212&_rows=10&_page=1&_sidx=invdate&_sord=desc&_filters=...

like you as need.

like image 190
Oleg Avatar answered Nov 02 '22 19:11

Oleg