是否可以在不使用DataView的情况下过滤Slickgrid?
如果不可能,应该如何构建数据数组才能正确显示?
我没有一个有效的例子atm。感谢
稍后编辑:
在完成更多的功课之后,可过滤的数据网格就是在嵌套数组中获取匹配的索引...以获得使用grid.setData(filterData)更新的实时排序结果集;网格渲染;一个人应该做以下
function intersect(a, b) // find an intersection of 2 arrays (google result on SO
{
var ai=0, bi=0;
var a = a.sort();
var b = b.sort();
var result = new Array();
while( ai < a.length && bi < b.length )
{
if (a[ai] < b[bi] ){ ai++; }
else if (a[ai] > b[bi] ){ bi++; }
else /* they're equal */
{
result.push(a[ai]);
ai++;
bi++;
}
}
return result;
}
// given results sets are arrays of indexes matching search criteria
a = [1,2,3,4];
b = [2,3,4,5];
c = [3,4,5,6];
d = [4,5,6,7];
// should reunite in a nested array
array = [a,b,c,d];
// check intersections for each array[k] and array[k+1]
k = array[0];
for (var i = 0; i<array.length-1; i++){
k = intersect(k,array[i+1]);
}
console.log(k) // returns 4
// k array is the index array that
// is used to build filterData[i] = data[j]
// depends if id is stored in data or in case
// of a database, it is stored in data
// tested in firebug
// thanks
答案 0 :(得分:3)
过滤基础数据数组并调用grid.setData(filteredData)
。