Nebula NatTable Integer column Sorting [message #1852098] |
Fri, 29 April 2022 00:12  |
Eclipse User |
|
|
|
Hello all,
I am trying to sort a column in the NatTable which has numeric values. Since the default data type for column values is String, default sorting happens in this column by string comparison. To make this column sorted by numeric values i registered custom comparator like this:
configRegistry.registerConfigAttribute(SortConfigAttributes.SORT_COMPARATOR, new MyCustomComparator(), DisplayMode.NORMAL, ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + intColIndex);
MyCustomComparator implements comparator using integer comparison
This registration of comparator does not do anything and the column sorts on string comparison instead of integer comparison.
Is there anything else i should do?
Any help, will be greatly appreciated.
Thanks in Advance
Regards
Teja
|
|
|
|
Re: Nebula NatTable Integer column Sorting [message #1852108 is a reply to message #1852101] |
Fri, 29 April 2022 08:18  |
Eclipse User |
|
|
|
Hi Dirk,
Thanks for the quick response and your solution. It worked out well for my problem. As you mentioned, I was missing the registration of ColumnLabelAccumulator.
For anyone with same problem, I registered ColumnLabelAccumulator like this:
ColumnOverrideLabelAccumulator labelAccumulator = new ColumnOverrideLabelAccumulator(columnHeaderDataLayer);
columnHeaderDataLayer.setConfigLabelAccumulator(labelAccumulator);
labelAccumulator.registerColumnOverrides(targetColIndex, ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + targetColIndex);
And then added my custom integer comparator like below:
configRegistry.registerConfigAttribute(SortConfigAttributes.SORT_COMPARATOR, MyCustomComparator(), DisplayMode.NORMAL, ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + targetColIndex);
[Updated on: Fri, 29 April 2022 08:18] by Moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03996 seconds