我有一个jqGrid与json数据类型和loadOnce:true.我正在使用filterToolBar搜索.它不会返回所有匹配项.网格包含一个名为Name的可搜索列,其值为“Adkins,Joe”和“Adkinson,Jane”.如果我输入搜索字符串“Adk”,则返回的唯一匹配是“Adkins,Joe”.
这是网格定义:
function loadmyGrid(dataUrl, selectUrl) {
$("#myGrid").jqGrid({
url: dataUrl + "?r=" + rand(),
datatype: "json",
mtype: 'GET',
rowNum: -1,
loadonce: true,
ignoreCase: true,
scroll: true,
scrollOffset: 0,
gridview: true,
colNames: ["Employee ID", "Name", "User Name", ""],
colModel: [
{ name: "EmployeeID", width: "125", align: "center", sortable: false, resizable: false, title: false, search: false },
{ name: "Name", width: "150", align: "center", sortable: false, resizable: false, title: false },
{ name: "UserName", width: "125", align: "center", sortable: false, resizable: false, title: false, search: false },
{ name: "UserKey", key: true, width: "135", align: "center", sortable: false, resizable: false, title: false, formatter: selectButtonFormatter, search: false},
],
emptyrecords: "Nothing to display",
beforeSelectRow: function () { return false; },
gridComplete: function () {
$("#myGrid").setGridHeight("100%");
$("#myGrid").filterToolbar({searchOnEnter: false, defaultSearch: "cn" })
}
})
最佳答案 你的主要错误是使用rowNum:-1这是错误的.如果要阻止本地数据分页,则应使用足够大的rowNum值.例如rowNum:1000或rowNum:10000.
我建议您另外将$(“#myGrid”)替换为任何回调(例如gridComplete)到$(this).使用“?r =”rand()部分网址似乎我不需要.调用$(“#myGrid”).filterToolbar你应该移出gridComplete,因为它只能被调用一次.
我建议你另外使用column templates.它可以减少代码,并使其更易于管理和更好的可读性.