FlowingCode / GridHelpers

Several grid recipes for Vaadin 23+ (and 22), ready to use. DOES NOT require extending Grid.
https://addonsv23.flowingcode.com/grid-helpers
Apache License 2.0
12 stars 1 forks source link

Enhanced Selection doesn't work with GridLazyDataView #109

Open deyaeddin opened 11 months ago

deyaeddin commented 11 months ago

when using Enhanced Selection with Lazy Data Provider, this exception is thrown.

java.lang.IllegalStateException: GridListDataView only supports 'ListDataProvider' or it's subclasses, but was given a 'AbstractBackEndDataProvider'. Use either 'getLazyDataView()', 'getListDataView()' or 'getGenericDataView()' according to the used data type. at com.vaadin.flow.data.provider.AbstractDataView.verifyDataProviderType(AbstractDataView.java:114) at com.vaadin.flow.data.provider.AbstractDataView.<init>(AbstractDataView.java:74)

javier-godoy commented 10 months ago

As mentioned in https://github.com/FlowingCode/GridHelpers/pull/110#issuecomment-1883122423, the current implementation iof this feature is intentionally restricted to in-memory data providers, because there is no efficient way to compute indexOf from a backend data provider. https://github.com/vaadin-component-factory/selection-grid-flow follows a different approach by capturing the indexes in the client-side, so that the data provider can resolve them.

mlopezFC commented 5 months ago

I have the following use case. I can host in memory all of the items, so I can use my grid without lazy loading, but the performance is slow, because every time that I enter in the grid I have to load all the items in memory. In certain cases (very few, rare I would say) I would need to select all the items to do a bulk operation (and my idea is to use enhanced selection for that), and in that time I don't mind in waiting to load all the items in memory. So if I understand well, is this feature only going to fetch all the items when I select a "big range" of the grid and in the rest of the cases just let the lazy loading mechanism to work as always?

javier-godoy commented 5 months ago

So if I understand well, is this feature only going to fetch all the items when I select a "big range" of the grid and in the rest of the cases just let the lazy loading mechanism to work as always?

If you are asking about the proposal in PR #110, it was rejected because selecting M items from a Grid with N items would be O(N), regardless of the size of that range, and selecting M items one at a time would be O(M*N), while an optimum solution would be O(M) in both cases. In comparison, selection-grid is O(M) and O(M^2) respectively.

Our limitation is that we designed the feature assuming that retrieving the index of an item is a cheap operation, which holds true for in-memory datasets.