如何在jqGrid中获取服务器端的搜索操作参数?

时间:2014-08-22 10:08:11

标签: jquery jsp jqgrid jqgrid-php

我输入了id过滤器框5,我在搜索操作中选择了更多。我在服务器端获得了id = 5的值,但我无法获得搜索运算符的value()

    jQuery("#list451").jqGrid({
    url: 'localset.do',
    datatype: "json",
    height: 255,
    width: 600,
    colNames: ['id', 'name', 'Code'],
    colModel: [{
        name: 'item_id',
        index: 'item_id',
        width: 65,
        sorttype: 'integer',
        searchoptions: {
            sopt: ['eq', 'ne', 'le', 'lt', 'gt', 'ge']
        }
    }, {
        name: 'name',
        index: 'name',
        width: 150,
        sorttype: 'string',
        searchoptions: {
            sopt: ['eq', 'bw', 'bn', 'cn', 'nc', 'ew', 'en']
        }
    }, {
        name: 'item_cd',
        index: 'item_cd',
        width: 100
    }],
    rowNum: 50,
    rowTotal: 200,
    rowList: [20, 30, 50],
    loadonce: false,
    mtype: "GET",
    rownumbers: true,
    rownumWidth: 40,
    gridview: true,
    pager: '#pager451',
    sortname: 'item_id',
    viewrecords: true,
    sortorder: "asc",
    caption: "Loading data from server at once"
});
jQuery("#list451").jqGrid('filterToolbar', {
    searchOperators: true
});

我试过postdata:{ filters: JSON.stringify(searchOper) }

我正在使用jsp servlet。

请求查询字符串是:

&page=&_search=false&nd=1408689334839&rows=10&page=1&sidx=&sord=asc&id=5

如何获取id搜索运算符值?

请帮助。

1 个答案:

答案 0 :(得分:1)

您应该使用filterToolbarstringResult: true选项。目前,您使用传统表单,它只发送名称和搜索选项的值。 jqGrid中随处可用的更新格式被描述为here。因此,有关过滤器和操作的所有信息都将作为一个filters参数发送。

我在所有生产代码中始终使用stringResult: truefilterToolbar(或multipleSearch: truemultipleSearch: true)中的multipleGroup: true选项。为了简化这些选项的使用,我设置了我最喜欢的搜索/过滤选项,包括像

这样的行
$.extend(true, $.jgrid.search, {
    jqModal: false,
    multipleSearch: true,
    multipleGroup: true,
    recreateFilter: true,
    closeOnEscape: true,
    searchOnEnter: true,
    overlay: 0,
    stringResult: true,
    defaultSearch: "cn"
});

直接包括grid.locale-en.jsjquery.jqGrid.min.js

当然,您必须调整服务器代码以解析filters参数。