Skip to main content



      Home
Home » Eclipse Projects » NatTable » Nebula NatTable Integer column Sorting(Registering custom comparator for integer column sorting does not work)
Nebula NatTable Integer column Sorting [message #1852098] Fri, 29 April 2022 00:12 Go to next message
Eclipse UserFriend
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 #1852101 is a reply to message #1852098] Fri, 29 April 2022 02:24 Go to previous messageGo to next message
Eclipse UserFriend
Well you need of course to register the ColumnLabelAccumulator on the column header DataLayer. Otherwise the label is not in the LabelStack of the column header cell that gets inspected by the SortHeaderLayer
Re: Nebula NatTable Integer column Sorting [message #1852108 is a reply to message #1852101] Fri, 29 April 2022 08:18 Go to previous message
Eclipse UserFriend
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

Previous Topic:Highlight Row reorder swapping of rows
Next Topic:Nattable fill by drag selection data
Goto Forum:
  


Current Time: Mon May 19 21:02:36 EDT 2025

Powered by FUDForum. Page generated in 0.03996 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top