【发布时间】:2020-10-24 23:13:16
【问题描述】:
当我尝试在“Erstellt Von”列中搜索字符串Test 时,我没有得到任何结果。控制台也没有错误。
这是我使用的代码部分:
var colUserTemplate = {
width: 160, align: 'left',
formatter: function (cellvalue, options, rowObject) {
return "Test";
}
}
在另一列中,过滤效果很好:
以下是网格的加载方式和filterToolbar:
function loadGrid(listname, query, divname, colnames, colmdodel, showFilter, showExcelExport) {
$("#" + divname).jqGrid({
datatype: function () { loadGridData(listname, query, divname); },
colNames: colnames,
colModel: colmdodel,
height: "100%",
loadonce: true,
rowNum: 9999,
gridComplete: function () {
$("#" + divname + "no").html(" [" + $("#" + divname).jqGrid('getGridParam', 'records') + "]");
$("#" + divname).jqGrid('setGridParam', { datatype: 'local' });
},
ondblClickRow: function (rowid, iRow, iCol, e) {
onDoubleClickGrid(rowid, iRow, iCol, e, divname, listname);
}
});
if (showFilter) {
$("#" + divname).jqGrid('filterToolbar', {
autosearch: true,
stringResult: false,
searchOnEnter: true,
defaultSearch: "cn",
});
}
}
我尝试过使用
if (showFilter) {
$("#" + divname).jqGrid('filterToolbar', {
autosearch: true,
stringResult: true,
searchOnEnter: true,
defaultSearch: "cn", ignoreCase: true
});
}
但它并没有改变任何东西。
如果你想看看,here's the full code.
数小时以来一直在尝试解决此问题,感谢您提供任何帮助!
编辑:
写这篇的时候:
var thegrid = $("#" + divname)[0];
console.log("data.d.results: " + data.d.results);
thegrid.addJSONData(data.d.results); //Binding data to the grid
console.log("thegrid:" + thegrid.innerHTML);
这是展开的对象:
【问题讨论】:
-
这是因为您使用了自定义格式化程序。该格式化程序返回您自己的值,而本地搜索是对存储在数据数组中的本地数据执行的。换句话说 - 网格不是在网格中显示的值上执行搜索,而是在这些存储到数据数组中的值上执行搜索。
-
感谢您的回复。那么我该怎么办呢?
-
将这些值首先放入响应中。您将数据类型用作函数,因此将格式化的值放在这里。
-
我究竟要写什么才能将格式化的值放入数据类型函数中?您能写一个答案,以便我将其标记为正确吗?
标签: javascript jquery sharepoint filter jqgrid