如何更改sidx,sord,jqGrid中的过滤器参数名称 [英] How to change sidx,sord,filters parameters names in jqGrid

查看:729
本文介绍了如何更改sidx,sord,jqGrid中的过滤器参数名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果列名是sidx,sord,filters,则获取数据的jqGrid损坏.我尝试使用下面的代码向其添加下划线,但这些参数仍在不带下划线的情况下传递.其他参数,例如_rowid,_page等,都必须正确地带有下划线.

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.

如何将sidx,sord,filters用作jqgrid中的列名?

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"
    }
});

推荐答案

我不明白在如果列名是sidx,sord,filters,jqGrid获取数据的情况下"的意思.但是,如果需要,可以使用两种方法重命名或删除jqGrid参数:prmNamesserializeGridData.

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.

您应该仔细检查 prmNames <的默认值列表/a>.不能用这种方式重命名filters,但是要重命名您应该使用的其他参数的名称

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"
    }
});

(sortorder而不是sidxsord).要将filters重命名为_filters并删除发送空的searchFieldsearchStringsearchOper,您可以执行与我描述的

(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;
}

使用提琴手 Firebug ,您可以验证演示使用以下参数

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=...

根据需要喜欢你.

这篇关于如何更改sidx,sord,jqGrid中的过滤器参数名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆