我现在使用 jqGrid(版本:jqGrid 4.14.1-pre,免费 jqGrid),其中有一列包含 searchOperators。
当我清除工具栏时出现问题。我的默认运算符是“<=(小于或等于)”。当我将运算符更改为其他并通过列的 x 按钮或 navGrid 的刷新按钮清除工具栏时,searchOperator 显示我之前选择的内容,但过滤为“<=”(默认值)。当我单击运算符以显示下拉弹出窗口时,它会突出显示默认值,即使显示的是不同的运算符,如下图所示。
This is demo我提到过,它不会重置为默认值,与我的情况不同。但我并没有发现它和我的有什么特别的区别。 (我认为自定义 searchOperator 可能并不重要......是吗?) 我发现的是clearToolbar(),但它似乎只重置了文本框值。
我不介意清除后留下什么样的运算符,但我唯一想要的就是显示正确的运算符。你能帮我一下吗?
以下是网格和工具栏代码。
tbLockedPartiesHistoryArea.jqGrid({
url: '/LockedObjects/GetLockedParties',
datatype: "json",
contentType: "application/json; charset-utf-8",
mtype: 'GET',
emptyrecords: "There is no locked parties currently.",
colModel: [
{label: 'LockedBy', name: 'LockedBy', sorttype: 'text', searchoptions: {clearSearch: true}},
{label: 'LockedDate', name: 'LockedDate', sorttype: 'date', searchoptions: {clearSearch: true},
sortable: true,
resizable: false,
hidden: false,
search: true,
formatter: 'date',
formatoptions: {srcformat: 'm/d/Y h:i:s A', newformat: 'm/d/Y h:i:s A'},
searchrules: {date: true},
searchoptions: {
sopt: ["dle", "deq", "ge"],
dataInit: function (element) {
var self = this;
$(element).datepicker({
dateFormat: 'mm/dd/yy',
changeYear: true,
changeMonth: true,
showButtonPanel: true,
onSelect: function () {
setTimeout(function () {
self.triggerToolbar();
}, 0);
}
});
}
}
}],
rowNum: 20,
rowList: [20, 30, 50],
prmNames: {
page: 'defaultPageNumber',
rows: 'rowsPerPage'
},
customSortOperations: {
deq: {}, //I will just cut this since the code gets too long
dle: {},
},
forceClientSorting: true,
rownumbers: true,
viewrecords: true,
loadonce: true,
multiselect: true,
multiPageSelection: false,
pager: true,
searching: {
searchOperators: true,
defaultSearch: 'cn',
closeOnEscape: true,
searchOnEnter: false,
multipleSearch: true
}
});
tbLockedPartiesHistoryArea.jqGrid('filterToolbar', {
ignoreCase: true,
searchOperators: true,
enableClear: false
});
tbLockedPartiesHistoryArea.jqGrid('navGrid', {
edit: false,
add: false,
del: false,
refresh: true,
refreshtext: "Clear Filter",
refreshtitle: "Clear Filter"
});
};
最佳答案
感谢您的错误报告!使用 customSortOperations
时存在问题(描述 here )。
我发布了the commit现在。请从GitHub获取最新的免费jqGrid来源。现在问题应该已经解决了。
关于javascript - jqGrid searchOperator 清除工具栏后显示错误的运算符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42908639/