How to change sidx, sord, filter parameter names in jqGrid

If the column names are sidx, sord, filters, jqGrid gets the data. I tried adding underscores to them using the code below, but these parameters are still passed without underscores. Other parameters, such as _rowid, _page, etc., are passed properly with underlining.

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" } }); 
+6
source share
1 answer

I do not understand what you mean by "If the column names are sidx, sord, filters, jqGrid, the data is received." However, if you need to, you can rename or remove jqGrid parameters in two ways: prmNames and serializeGridData .

You should carefully examine the prmNames default list of values. There is no way to rename filters in the path, 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 remove sending empty searchField , searchString and searchOper , you can do almost the same thing as I described here 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 check that the following parameters are used in the demo URL

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

like you if you need to.

+10
source

Source: https://habr.com/ru/post/894967/


All Articles