jquery - 如何禁用 jqGrid 中选定列的搜索选项?

标签 jquery jqgrid jqgrid-php

我有一个带有列过滤器的五列(2 个整数,3 个字符串列)网格。我想要对整数值(大于、小于、等于)进行搜索操作,它工作正常,我不想对字符串列进行搜索操作。

我正在使用后端搜索。

我所期待的是下面附上的模型图片,请找到它

我想要搜索,但我不希望对具有列的字符串进行搜索操作

如何删除所选列中的搜索操作。请帮助我。

enter image description here

jQuery("#list451").jqGrid({
    url: 'localset.php',
    datatype: "json",
    height: 255,
    width: 600,
    colNames: ['Index', 'Name', 'Code', 'N Name', 'C Name'],
    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: []
            }
        }, {
            name: 'code',
            index: 'code',
            width: 150,
            sorttype: 'string',
            searchoptions: {
                sopt: ['eq', 'bw', 'bn', 'cn', 'nc', 'ew', 'en']
            }
        }, {
            name: 'n_name',
            index: 'n_name',
            width: 150,
            sorttype: 'string',
            searchoptions: {
                sopt: []
            }
        }, {
            name: 'c_name',
            index: 'c_name',
            width: 150,
            sorttype: 'string',
            searchoptions: {
                sopt: []
            }
        },
        rowNum: 50,
        rowTotal: 200,
        rowList: [20, 30, 50],
        loadonce: true,
        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
});

最佳答案

colModel 中使用 search:false 来查找不需要搜索的列。

更新
您可以通过将 searchoptions: 替换为 searchrules

来自定义网格中的搜索选项
searchrules:{custom:true, custom_func: fnc_myStringCheck }, search:true }   

确保您的自定义方法的stype为文本(尽管默认情况下是这样)和fnc_myStringCheck。 希望这会有所帮助。

关于jquery - 如何禁用 jqGrid 中选定列的搜索选项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25500284/

相关文章:

jquery - free-jqgrid:setCell 将 css 类添加到单元格

javascript - JqSuite PHP : get column name or id?

php - 如何使用 jqgrid 发布数据中的 PHP 数组重新格式化 m/d/y 中的日期?

php + jqgrid + 导出到 excel

php - 创建动态 jQuery SlideToggle div,通过 Google Analytics 跟踪点击次数

javascript - 如何在 Bootstrap 上触发下拉按钮模糊/关闭事件?

javascript - 关于 document.ready 的 JQuery 解释

jquery - Bootstrap 4 - Tabs 滑动效果

javascript - jquery 网格中的过滤器工具栏中未填充下拉列表

jquery - 如何增加 jqgrid 标题复选框的大小