我正在使用光滑网格v2.2,在网格中我添加了搜索功能来过滤行,在我的代码下面我使用dataview进行搜索,在代码“(gridFilter)”不是射击&抛出错误为Uncaught SyntaxError:意外的令牌,,如果我错了请更正我的代码,提前致谢。
$('#textSearch-inputEl').keyup(function () {
if (e.which === 27) {
this.value = "";
}
var searchList = $.trim(this.value.toLowerCase()).split(' ');
dataView.setFilter(gridFilter);
grid.invalidate();
this.focus();
});
function gridFilter(rec) {
var found;
var gridSearchList = dataView.getLength();
for (var i = 0; i < dataView.getLength(); i += 1) {
found = false;
$.each(rec, function(obj, objValue) {
if (typeof objValue !== 'undefined' && objValue !== null
&&
objValue.toString().toLowerCase().indexOf(gridSearchList[i]) !== -1) {
found = true;
return false;
}
});
if (!found) {
return false;
}
}
return true;
}
答案 0 :(得分:0)
在gridFilter()
中尝试此代码 var found;
for (var i = 0; i < searchData.length; i += 1) {
found = false;
$.each(rec, function (obj, objValue) {
if (typeof objValue !== 'undefined' && objValue !== null && objValue.toString().toLowerCase().indexOf(searchData[i]) !== -1) {
found = true;
return false;
}
});
if (!found) {
return false;
}
}
return true;