As a suggestion from question Nattable add row command I tried to register a command handler with an EventList
.
But since the Eventlist
is wrapped by a FilterList
which acts as BodyDataProvider
I could not create a DataLayer
based in EventList
from which I could register my CommmandHandler
.
The starting point is the previous question to define a BodyLayerStack
with the following:
class BodyLayerStack extends AbstractLayerTransform {
//AncolabMaterial is the model to show at the natTable
private final EventList<AncolabMaterial> filterList;
private final IDataProvider bodyDataProvider;
private final SelectionLayer selectionLayer;
public BodyLayerStack(List<AncolabMaterial> input_values_list, IColumnPropertyAccessor<AncolabMaterial> columnPropertyAccessor) {
EventList<AncolabMaterial> eventList = GlazedLists.eventList(input_values_list);
TransformedList<?, ?> rowObjectsGlazedList = GlazedLists.threadSafeList(eventList);
SortedList<?> sortedList = new SortedList<>(rowObjectsGlazedList, null);
this.filterList = new FilterList<AncolabMaterial>((EventList<AncolabMaterial>) sortedList);
this.bodyDataProvider = new ListDataProvider<AncolabMaterial>(filterList, columnPropertyAccessor);
DataLayer bodyDataLayer = new DataLayer(getBodyDataProvider());
//Other layers stacked
GlazedListsEventLayer<?> glazedListsEventLayer = new GlazedListsEventLayer<AncolabMaterial>(bodyDataLayer, this.filterList);
this.selectionLayer = new SelectionLayer(glazedListsEventLayer, false);
//...
}
}
I have tried the following:
DataLayer dataLayer = new DataLayer(
new ListDataProvider<AncolabMaterial>(eventList, columnPropertyAccessor));
But since DataLayer
wraps the IDataProvider
, and serves as the data source for all other layers, If I sets the EvenList
as the IDataProvider
of the DataLayer
then filterlList
is not working properly.
i.e. this.filterList
is not the base of the bodyDataProvider
.
I have not find at nattable_examples -> tutorial examples -> GlazedLists -> Filter any other BodyLayerStack
configuration different than the above.
There seems to be a big misunderstanding with regards to the list instances. If you want to use the filter functionality the shown
BodyLayerStack
is correct. You have to use theFilterList
in theIDataProvider
. There is absolutely now reason to change that!For the command handler you need to use the base
EventList
instance. Of course that does not work if you use the list that you get from theIDataProvider
. You need to provide the access to theEventList
in another way. From the snippets you show in this and in the other related post, I don't see a reason why you access the underlying list viaIDataProvider
, but as you already noticed, that does not work. You need to change your code structure.