GroupBy - how to refresh groups after data changed? [message #1744603] |
Wed, 28 September 2016 15:38  |
Eclipse User |
|
|
|
Hi,
I'm working with Nattable (and I'm fascinated how well it works), but I'm stumbling over a problem: I'm using the GroupBy feature. When I have the data grouped, I start updating some of the data in the grouped columns. So for example, I have data grouped by the column 'Last Name' and I change the last name of one row from 'Meyer' to 'Mayer'.
My expectation was that the grouping of the data would be re-calculated (and a new group 'Mayer' would be created and the row moved to the new group). But this does not happen. Calls like
groupByDataLayer.refresh();
groupByModel.update();
natTable.doCommand(new VisualRefreshCommand());
groupByDataLayer.killCache();
etc. don't help.
What do I need to do here?
Thank you and regards,
Godot
|
|
|
|
Re: GroupBy - how to refresh groups after data changed? [message #1744747 is a reply to message #1744737] |
Thu, 29 September 2016 17:01   |
Eclipse User |
|
|
|
Hi,
thank you! This doesn't feel straightforward, though (it feels expensive - actually, only a single row would have to be moved, ideally...).
In the meantime, I had come up with a different workaround solution which is probably similarily expensive:
bodyDataLayer.registerCommandHandler(new ILayerCommandHandler() {
@Override
public Class getCommandClass() {
return UpdateDataCommand.class;
}
@Override
public boolean doCommand(ILayer targetLayer, final ILayerCommand cmd) {
// some stuff to do the UpdateData goes here (actually, I'm using command and an EditingDomain here to support Undo/Redo, but that's not important...)
// test if we are really modifying data which requires a tree structure update
if (groupByModel.getGroupByColumnIndexes().contains(((UpdateDataCommand)cmd).getColumnPosition())) {
// read out the tree structure, clear it, rebuild it
List<Integer> groups = new LinkedList<Integer>();
groups.addAll(groupByModel.getGroupByColumnIndexes());
groupByModel.clearGroupByColumnIndexes();
for (Integer index: groups)
groupByModel.addGroupByColumnIndex(index);
}
return true;
}
});
Regards,
Joachim
P.S.: I'll go with your solution because admittedly, mine only works if there are no dependencies between the values of columns...
[Updated on: Thu, 29 September 2016 17:03] by Moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.27071 seconds