Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Single click sorting doesn't work anymore
Single click sorting doesn't work anymore [message #1464746] Fri, 07 November 2014 21:01 Go to next message
Thomas Zwickl is currently offline Thomas ZwicklFriend
Messages: 37
Registered: May 2014
Member
I've reconfigured my nattable to meet our new requirements and although I haven't changed anything on the NatTable itself, I added only a few new layers, I cannot sort the rows anymore with a single click in the column header.
I still have the following line in my code which just adds the SingleClickSortConfiguration to the NatTable:

natTable.addConfiguration(new SingleClickSortConfiguration());


But when I click into the header absolutely nothing happens. It just seems as there wouldn't be any button at all. Before this change it worked perfectly, but now after adding a few more layers it won't.
Here some code from my configuration:

Creating the filter list and the sort list:
FilterList<T> filterList = new FilterList<T>(eventList);
SortedList<T> sortedList = new SortedList<T>(filterList, null);

ColumnGroupModel columnGroupModel = new ColumnGroupModel();
final IDataProvider columnHeaderDataProvider = this.createColumnHeaderDataProvider(columnPropertyAccessor);


My body layer:
bodyDataProvider = new GlazedListsDataProvider<T>(eventList, columnPropertyAccessor);
bodyDataLayer = new DataLayer(bodyDataProvider);
glazedListsEventLayer = new GlazedListsEventLayer<T>(bodyDataLayer, eventList);
columnReorderLayer = new ColumnReorderLayer(glazedListsEventLayer);
columnGroupReorderLayer = new ColumnGroupReorderLayer(columnReorderLayer, columnGroupModel);
columnHideShowLayer = new ColumnHideShowLayer(columnGroupReorderLayer);
columnGroupExpandCollapseLayer = new ColumnGroupExpandCollapseLayer(columnHideShowLayer, columnGroupModel);
selectionLayer = new SelectionLayer(columnGroupExpandCollapseLayer);
viewportLayer = new ViewportLayer(selectionLayer);
freezeLayer = new FreezeLayer(selectionLayer);
compositeFreezeLayer = new CompositeFreezeLayer(freezeLayer, viewportLayer, selectionLayer);
setUnderlyingLayer(compositeFreezeLayer);


My column header:
columnHeaderDataProvider = dataProvider;
columnHeaderDataLayer = new DefaultColumnHeaderDataLayer(columnHeaderDataProvider);
columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer, bodyLayer, selectionLayer);
SortHeaderLayer<T> sortHeaderLayer = new SortHeaderLayer<T>(columnHeaderLayer, new GlazedListsSortModel<T>(
				sortedList, columnPropertyAccessor, configRegistry, columnHeaderDataLayer), false);

columnGroupHeaderLayer = new ColumnGroupHeaderLayer(sortHeaderLayer, selectionLayer, columnGroupModel);

CompositeMatcherEditor<T> autoFilterMatcherEditor = new CompositeMatcherEditor<T>();
filterList.setMatcherEditor(autoFilterMatcherEditor);
FilterRowHeaderComposite<T> composite = new FilterRowHeaderComposite<T>(
				new DefaultGlazedListsFilterStrategy<T>(autoFilterMatcherEditor, columnPropertyAccessor, configRegistry),
				columnGroupHeaderLayer, columnHeaderDataProvider, configRegistry);
setUnderlyingLayer(composite);

Then I create my row header and corner and add this all into a grid layer
// Row header
DefaultRowHeaderDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(bodyDataProvider);
DefaultRowHeaderDataLayer rowHeaderDataLayer = new DefaultRowHeaderDataLayer(rowHeaderDataProvider);
RowHeaderLayer rowHeaderLayer = new RowHeaderLayer(rowHeaderDataLayer, bodyLayer, bodyLayer.getSelectionLayer());

// Corner
DefaultCornerDataProvider cornerDataProvider = new DefaultCornerDataProvider(
				columnHeaderLayerStack.getColumnHeaderDataProvider(), rowHeaderDataProvider);
DataLayer cornerDataLayer = new DataLayer(cornerDataProvider);
CornerLayer cornerLayer = new CornerLayer(cornerDataLayer, rowHeaderLayer, columnHeaderLayerStack);

// Grid
gridLayer = new GridLayer(bodyLayer, columnHeaderLayerStack, rowHeaderLayer, cornerLayer, useDefaultConfiguration);

// add editing handler for filter
gridLayer.addConfiguration(new DefaultEditConfiguration());


At last I create my NatTable:
natTable = new NatTable(parent, gridLayer, false);
natTable.setConfigRegistry(configRegistry);
...
Lot of other code for formatting the NatTable and adding a custom popup menu
...
natTable.addConfiguration(new SingleClickSortConfiguration());
natTable.configure();


Any ideas where the problem could be?

[Updated on: Sat, 08 November 2014 03:33]

Report message to a moderator

Re: Single click sorting doesn't work anymore [message #1464823 is a reply to message #1464746] Fri, 07 November 2014 22:26 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2803
Registered: July 2012
Senior Member
Are you calling natTable.configure() before or after adding the configuration?
Re: Single click sorting doesn't work anymore [message #1465077 is a reply to message #1464823] Sat, 08 November 2014 03:34 Go to previous messageGo to next message
Thomas Zwickl is currently offline Thomas ZwicklFriend
Messages: 37
Registered: May 2014
Member
I call natTable.configure() at the end after I've added all the configuration ...

[Updated on: Sat, 08 November 2014 03:35]

Report message to a moderator

Re: Single click sorting doesn't work anymore [message #1465162 is a reply to message #1465077] Sat, 08 November 2014 05:17 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2803
Registered: July 2012
Senior Member
Then it might be related to the column header composition. Maybe you need to set the SortHeaderLayer on top of the column group header. Please check against an integration example. IIRC I created one for that case.
Re: Single click sorting doesn't work anymore [message #1465523 is a reply to message #1465162] Sat, 08 November 2014 12:25 Go to previous messageGo to next message
Thomas Zwickl is currently offline Thomas ZwicklFriend
Messages: 37
Registered: May 2014
Member
OK I could now narrow down the problem to the following two lines:
// create persistence dialog
DisplayPersistenceDialogCommandHandler persistenceDialogHandler = new DisplayPersistenceDialogCommandHandler(natTable);
glazedListsGridLayer.getBodyLayer().registerCommandHandler(persistenceDialogHandler);

When I call these lines before I call natTable.configure() my single click sorting won't work, but when I move these two lines behind the natTable.configure() everything works fine. I haven't figured out what the reason is for that behaviour but maybe one of you knows what's the problem here.

[Updated on: Sat, 08 November 2014 12:28]

Report message to a moderator

Re: Single click sorting doesn't work anymore [message #1465714 is a reply to message #1465523] Sat, 08 November 2014 16:20 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2803
Registered: July 2012
Senior Member
The persistence dialog only works correct with the NatTable parameter in case it is called AFTER configure(). IIRC the reason is that this constructor persists the initial state of the given NatTable instance. But it has no states yet since configure() wasn't called. Should add that to the Javadoc.
Re: Single click sorting doesn't work anymore [message #1465777 is a reply to message #1465714] Sat, 08 November 2014 17:34 Go to previous message
Thomas Zwickl is currently offline Thomas ZwicklFriend
Messages: 37
Registered: May 2014
Member
Yeah of course you're right ... What should it persist if the NatTable itself isn't even configured ...
Thanks for the clarification Wink
Previous Topic:Unhide one column
Next Topic:Is The Given Problem Statement Possible in Nattable
Goto Forum:
  


Current Time: Mon Mar 08 07:35:36 GMT 2021

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

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

Back to the top