How to get size of filtered dataprovider?


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,

This is related to other question, see link below

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:

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