jquery - jqGrid "_search"参数始终为 false

标签 jquery jsp jqgrid

我在代码中使用 jqGrid,但遇到了一些问题。
以下是 asd.jsp 中的代码:

jQuery().ready(function ()
{

    $("#myGridId").jqGrid({
        url: "getListAsd.jsp",
        datatype: "json",
        colNames: ['menu', 'name', 'price'], 
        colModel: [
            {index: "menu", width: 250, sortable: true, editable: true, edittype: "text"},
            {index: "name", width: 250, sortable: true, editable: true, edittype: "text"},
            {index: "price", width: 100, sortable: true, editable: true, edittype: "text", align: "right"}
        ],
        rowNum: 35,
        height: 780,
        autowidth: false,
        sortname: "price",
        sortorder: "desc", 
        viewrecords: true,         
        pager: '#gridpager',
    })                
            .jqGrid('filterToolbar', { searchOnEnter: true, enableClear: true }) // make search available in each column
            .navGrid('#gridpager', {edit: true, add: true, del: true, search: false, view: false},
                    {multipleSearch: true} // search options
            );
});

这是来自 getListAsd.jsp 的代码:

if (request.getParameter("_search") != null) {
    search = java.lang.Boolean.parseBoolean(request.getParameter("_search"));
}
if (search) {
    // some search things here...
}

在 gridpager 中,我需要 search: false 因为我想在每一列中进行搜索,而不是使用默认搜索按钮。
所以问题是 _search 总是 false。

最佳答案

问题已解决。 看来 jqGrid 需要 name 属性才能正确执行列内搜索。
来自 asd.jsp 的新代码:

colModel: [
        {name: "menu", index: "menu", width: 250, sortable: true, editable: true, edittype: "text"},
        {name: "name", index: "name", width: 250, sortable: true, editable: true, edittype: "text"},
        {name: "price", index: "price", width: 100, sortable: true, editable: true, edittype: "text", align: "right"}
    ],

关于jquery - jqGrid "_search"参数始终为 false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43845520/

相关文章:

javascript - JQGrid 和搜索引擎索引

javascript - jqGrid v4.0 使用本地数据类型时分页器不工作

javascript - 使用 jQuery 在 div 中随机淡入淡出

javascript - 单击按钮时如何从 ul 中解开所有 li

javascript - 验证该值不在数据库中

java - 在 JSP 中计算和显示 float

java - 检测新的 HttpSession

java - 无法访问 WEB-INF/folder/folder/file.jsp

jquery - 当我更改下拉列表时如何在 asp.net mvc 中重新加载 jqgrid

javascript - 循环数组,附加输入文本框,然后设置这些文本框的值