Im trying to figure out how to get the current filtered items from the Griddle component.
I found the following function in the source-code:
var filteredDataSelector = exports.filteredDataSelector = (0, _reselect.createSelector)(dataSelector, filterSelector, function (data, filter){
return data.filter(function (row) {
return Object.keys(row.toJSON()).some(function (key) {
return row.get(key) &&
row.get(key).toString().toLowerCase().indexOf(filter.toLowerCase()) > -1;
});
});
});
But how would I use the filteredDataSelector in my react-component? I would like to get the filtered items when clicking a button export to excel.
I found this example on how to interact with each item (to render hyperlink instead of just plain text) in the list which I think should work in a similair way to what I want to achieve: https://github.com/GriddleGriddle/Griddle/issues/586
I dont really understand how this works with redux and the connect function, but example above worked just fine.
Not sure if I have to use redux/connect in a similair way to get the filtered list of items?
Griddle-documentation: https://griddlegriddle.github.io/Griddle/docs/
Found a way to solve this, even though Im pretty sure there is a better solution, then please let me know.
First I overrided the TableBody griddle-component and also made a small fix to get it work properly in internet explorer 11, ie11 (list._tail.array). I store the currently filtered datarow indexes in this.rowIds.
Using the rowDataSelector as explained in this article: https://griddlegriddle.github.io/Griddle/examples/getDataFromRowIntoCell/ and then using the rowIds field to get the selected data, only at the first row-index.
Using it:
Final code: