Reputation: 2759
I'm using NatTable for the first time. I have already created a nice Table with sorting, filtering, ... But now I'm searching for a way to implement a change listener that will be called everytime the data in the table has been changed. Also the event need to give me the changed model back.
It there any way to create this behaviour?
Upvotes: 0
Views: 938
Reputation: 4231
As NatTable is basically "only" a viewer for a data model, I typically would suggest to introduce some sort of PropertyChangeListener on the model object. The reason is that the data can be changed via NatTable or in the data model itself via background tasks. In the end the answer will be dependent on your use case.
If you only want to track changes in NatTable in a special way, you could implement and register a custom UpdateDataCommandHandler
that fires an event with the information you need. In NatTable itself we currently don't fire such events. In case of data updates we only fire a CellVisualChangeEvent
to trigger repainting.
A basic explanation on how to exchange the behavior for data updates can be found at the bottom of this page: https://www.eclipse.org/nattable/documentation.php?page=editing
In the end you will need to check the implementation of UpdateDataCommandHandler
, basically do the same actions to update the data model and additionally fire an event that matches your expectation.
Upvotes: 1