I understand that I have to use grid.getDataProvider() to get the ListDataProvider (assuming I sent a List to grid.setItems()). In other to calculate the footer total I do:
If I do the initial loop way above it includes even the filtered items. In other words how can I get a total for only those items that are visible in the grid, the filtered items?
Instead of getItems() you should use fetch(…) method of the data provider. With fetch you can apply same filters with a Query or sorting than in Grid, and get stream of items, that matches what you want.
I looked at that but fetch() requires a query which I don’t understand. Also how does it link to the filters. Would you be so kind as to provide a code example because I have no idea how the query parameter of fetch() works. Also if you have any links to documentation that would be appreciated. All I could find was the API and it had no details or examples other than saying it was a query…
fetchItemsWithRange() is a protected method. Also how do you know what the range is because the items are filtered? The link is just to get an item at a specific index, I don’t understand how it would work. I don’t know which items are present because the data is filtered…
What would be the parameter of fetchItemsWithRange? Would it be 0, myList.size() ? I ask because tried that and the result was nothing was filtered.
Or maybe as you said use the fetch() method, but the problem is that I don’t understand how to use it. What do I use for the Query parameter?
Just to re-iterate what I’m trying to do is reload the grid after an action has taken place. Not necessarily a delete but some other action which can affect multiple rows, etc. And when I reload the filters need to be re-applied.
I have the same question. What should be the parameter for fetchItemsWithRange() ?
I have a TreeGrid with sum being displayed in the footer. When there is a filter applied to the grid, I want the sum to update.
Can’t seem to understand the syntax.
FYI i also tried using fetch() → it says non hierarchical queries are not allowed for heirarchical, so i tried using fetchChildren - that requires HierarchicalQuery instead of Query which again, i dont understand what should be the parameter for that…