Hi
I am trying to extract data from a GRIDPro component. I need to be able to extract the current items in the grid as they appear on the screen (honouring the current filters applied and sort order).
I found the following code example to do this but I have run into a problem because I am using a CallbackDataprovider.
ListDataProvider<Type> lDataProvider = (ListDataProvider<Type>) grid.getDataProvider();
int totalSize = lDataProvider.getItems().size();
MLOGGER.info("Current size of grid with filters on = " + totalSize);
DataCommunicator<Type> dataCommunicator = grid.getDataCommunicator();
Stream<Type> stream = lDataProvider.fetch(new Query<>(
0,
totalSize,
dataCommunicator.getBackEndSorting(),
dataCommunicator.getInMemorySorting(),
lDataProvider.getFilter()));
List<Type> list = stream.collect(Collectors.toList());
MLOGGER.info("Size of extracted list = " + list.size());
However I get the following class cast error at runtime.
java.lang.ClassCastException: com.vaadin.flow.data.provider.CallbackDataProvider cannot be cast to com.vaadin.flow.data.provider.ListDataProvider
Does anyone know a way around this? I am using Vaadin 14.4 at the moment and would like to stay on this LTS version.
Thanks, John