Slickgrid Filtering without Dataview

匿名 (未验证) 提交于 2019-12-03 03:04:01

问题:

Is it possible to filter a Slickgrid without using the DataView?

In case it isn't possible, how should the data array be structured in order to display correctly?

I don't have a working example atm. Thanks

Later edit:

After doing some more homework, a filterable datagrid is all about getting matching indexes in a nested array... to get a live sorted result-set that gets updated with grid.setData(filterData);grid render; one should do the following

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 

回答1:

Filter the underlying data array and call grid.setData(filteredData).



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!