我有一个带有列过滤器的五列(2 个整数,3 个字符串列)网格。我想要对整数值(大于、小于、等于)进行搜索操作,它工作正常,我不想对字符串列进行搜索操作。
我正在使用后端搜索。
我所期待的是下面附上的模型图片,请找到它
我想要搜索,但我不希望对具有列的字符串进行搜索操作
如何删除所选列中的搜索操作。请帮助我。
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/