How to get size of filtered dataprovider?

Hi,

I created a ListDataProvider, and set a filter using method “setFilter”. Are there any simple methods which could provide the size information after filtering?

Best regards,
Joey

This is related to other question, see link below

https://vaadin.com/forum/thread/17370568/how-to-get-all-filtered-items-of-grids-in-vaadin-8

The answer is to use grid.getDataCommunicator().fetchItemsWithRange(…) and get size of the result.

Thanks a lot. Joey

Hi Joey,

But if you are using Vaadin Flow, the name of the method is different, fetchFromProvider, and it is not public yet, see:

https://github.com/vaadin/flow/issues/4510

Hi,
Hope can help the other with same problem.
You can get size from filtered dataprovider with this way.
dataProvider.size(new Query<>(dataProvider.getFilter()));

Solution found in stackoverflow
https://stackoverflow.com/questions/60164540/after-filtering-get-count-of-items-currently-displayed-in-a-grid-widget-in-vaad