Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

access list of filtered items in dataview

Tags:

slickgrid

I'm using a DataView to populate the Grid, and using filters to interact with the visible rows. My problem is after applying the filters, on rows change, or rows count change... how can I access the dataview to iterate over only those visible rows, to do some calculations for example?

Because rows themselves are not publicly exposed... and if they were, a row is not always a data element, since can also refer to a Group, right?

Is there an easy way to access those filtered data elements then?

(I guess what I'm looking for is something like being able to access "var filteredItems = getFilteredAndPagedItems(_items, _filter);")

thanks,

like image 847
Marc Avatar asked Mar 10 '11 06:03

Marc


2 Answers

Use dataView.getLength() and dataView.getItem(index) to access filtered/paged/grouped data. This is the interface the grid is using to talk to the data source.

like image 90
Tin Avatar answered Nov 11 '22 21:11

Tin


I posted a solution here if you want to give that a look. Also for those who might be looking for something similar.

Get Filtered data from Dataview in Slickgrid

if you want to show the information that's being filtered and whats on the current page you can do something like this.

var pagingInfo = dataView.getPagingInfo();
var start = pagingInfo['pageSize'] * (pagingInfo['pageNum']);
var filteredAndPagedItems = dataView.getFilteredItems().slice(start,(start + pagingInfo['pageSize']));
console.table(filteredAndPagedItems);

something along those lines.the getFilteredItems is a custom function i added to the dataview.js. for more information view the link.

like image 42
Joshua JLIVE Williams Avatar answered Nov 11 '22 21:11

Joshua JLIVE Williams