vaadin-component-factory / selection-grid-flow

Add the functionality to Vaadin Grid to focus on a particular row and column and select a range of rows with SHIFT/CTRL Click
https://incubator.app.fi/selection-grid-flow-demo/
Apache License 2.0
4 stars 8 forks source link

Fix for #20 (support data provider interfaces instead of TreeDataProvider) #23

Closed stefanuebe closed 3 years ago

stefanuebe commented 3 years ago

https://github.com/vaadin-component-factory/selection-grid-flow/issues/20

jcgueriaud1 commented 3 years ago

I reverted the PR. At least it requires a demo with a dataprovider that is not a TreeDataProvider. I think it's not working since internally the component is using TreeData: https://github.com/vaadin-component-factory/selection-grid-flow/blob/main/selection-grid-flow/src/main/java/com/vaadin/componentfactory/selectiongrid/SelectionTreeGrid.java#L122

It's probably not needed for the selection but it's required for the focus method.

stefanuebe commented 3 years ago

I reverted the PR. At least it requires a demo with a dataprovider that is not a TreeDataProvider. I think it's not working since internally the component is using TreeData: https://github.com/vaadin-component-factory/selection-grid-flow/blob/main/selection-grid-flow/src/main/java/com/vaadin/componentfactory/selectiongrid/SelectionTreeGrid.java#L122

It's probably not needed for the selection but it's required for the focus method.

Hm, did not see that. How about an additional interface HasTreeData, that provides the TreeData? If the data provider is a TreeDataProvider, it uses directly its TreeData. If not, then the data provider needs to implement HasTreeData. If that is also not the case, then it throws an UnsupportedOperationException or IllegalStateException.

stefanuebe commented 3 years ago

Or maybe even more generic a "HasParentProvider" or similar, which takes an item and returns the parent for it. This would allow to use a hierarchical data provider, that not needs to use a TreeData instance.

jcgueriaud1 commented 3 years ago

You don't need to check this, it's already checked in the TreeGrid. It has to be a HierarchicalDataProvider. What is the use case for not using a TreeDataProvider but that requires a dataprovider that requires a TreeData?