remove data when table is sorted [message #1087320] |
Thu, 15 August 2013 13:15 |
David Hein Messages: 3 Registered: May 2013 |
Junior Member |
|
|
Hello,
I have a Nattable which is based on a EMF model. If something is added or removed from the model then I got a notification via EMF and I add or remove this object from my EventList in the Nattable. This is working fine, but only for not sorted tables.
If I sort a column and remove then a object then I got strange row indexes in my IConfigLabelAccumulator. The index is then -1. Thats only happens when a column is sorted.
My implementation looks like:
...
//The three lists I need for my table
TransformedList<MyObject, MyObject> baseEventList = GlazedLists.threadSafeList(GlazedLists.eventList(myObjects));
FilterList<MyObject> filterList = new FilterList<MyObject>(baseEventList);
SortedList<MyObject> sortedList = new SortedList<MyObject>(filterList, null);
...
...
//My data provider, which implements Adapter from EMF to get notifications about the model change. If something is changed in the model I do the specific modification on the list.
public class MyRowDataProvider extends GlazedListsDataProvider<MyObject> implements Adapter {
public CSMInstanceRowDataProvider(EventList<MyObject> eventList,
IColumnPropertyAccessor<MyObject> columnPropertyAccessor, EMFObject emfObject) {
super(eventList, columnPropertyAccessor);
emfObject.eAdapters().add(this);
}
@Override
public void notifyChanged(Notification notification) {
if (notification.getEventType() == Notification.REMOVE) {
if (notification.getOldValue() instanceof MyObject) {
this.list.remove(notification.getOldValue());
}
}
else if (notification.getEventType() == Notification.ADD) {
if (notification.getNewValue() instanceof MyObject) {
this.list.add((MyObject) notification.getNewValue());
}
}
}
...
What happens if a column is sorted? Is it correct that nattable will react automatically if there are changes on the Eventlist? I also tried to do a nattable.refresh(), but this also did not work.
Thanks, David
|
|
|
|
Powered by
FUDForum. Page generated in 0.03665 seconds