使用数据视图问题的平滑网格搜索?
Slick grid search using data view issue?
我正在使用 slick grid v2.2,在网格中我添加了搜索功能来过滤行,在我的代码下方我使用了数据视图进行搜索,在代码中 "(gridFilter)" 未触发并抛出错误,如 Uncaught SyntaxError: Unexpected token ,,如果我错了,请更正我的代码,在此先感谢。
$('#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;
}
在 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;
我正在使用 slick grid v2.2,在网格中我添加了搜索功能来过滤行,在我的代码下方我使用了数据视图进行搜索,在代码中 "(gridFilter)" 未触发并抛出错误,如 Uncaught SyntaxError: Unexpected token ,,如果我错了,请更正我的代码,在此先感谢。
$('#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;
}
在 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;