Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Having problems to add sorting functionality(Sorting without GlazedLists)
Having problems to add sorting functionality [message #1403785] Sun, 27 July 2014 12:56 Go to next message
Timon Langlotz is currently offline Timon LanglotzFriend
Messages: 1
Registered: July 2014
Junior Member
Hello,

I am having some troubles to add the sorting functionality to my NatTable.
I implemented a DataProvider (TableDataProvider) for the header and content of my NatTable and a SortModel.

This is my code:
TableDataProvider headerProvider = new TableDataProvider(header);
TableDataProvider contentProvider = new TableDataProvider(result.getRows());

table = new NatTable(container, new DefaultGridLayer(contentProvider,
				headerProvider), true);

SortModel sortModel = new SortModel(result);
//What now?


What do I have to do now to add the sorting functionality? I looked at the example in the documentation, but wasn't able to determine what I would have to do! Sad

Thank you very much!
Timon
Re: Having problems to add sorting functionality [message #1403803 is a reply to message #1403785] Sun, 27 July 2014 19:40 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
You are using the DefaultGridLayer instead of building a custom GridLayer. You need to add the SortHeaderLayer to the column header layer stack. That is what the example should show.

You could also try to have a look at the examples attached to the articles linked on our website.
Re: Having problems to add sorting functionality [message #1445337 is a reply to message #1403803] Wed, 15 October 2014 09:52 Go to previous messageGo to next message
Kai Mechel is currently offline Kai MechelFriend
Messages: 6
Registered: July 2009
Junior Member
Maybe he is also using Persistence? After calling
natTable.loadState(...);

my formerly working sortable header is not working anymore. Sorting functionality is dead.

Is this a known Bug?
There is also no example doing both - sorting & persistence. At least I could not find a blueprint to make that work.

Many regards
Kai
Re: Having problems to add sorting functionality [message #1445357 is a reply to message #1445337] Wed, 15 October 2014 10:20 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Quote:
Is this a known Bug?


No!

There is no explicit example for that because it normally shouldn't be necessary. I suppose you have done something wrong in your ISortModel. If I modify the SortHeaderLayerExample using the DisplayPersistenceDialogCommandHandler I am able to save and load states as much as I like and still be able to sort.
Re: Having problems to add sorting functionality [message #1446643 is a reply to message #1445357] Fri, 17 October 2014 05:18 Go to previous messageGo to next message
Kai Mechel is currently offline Kai MechelFriend
Messages: 6
Registered: July 2009
Junior Member
Hi Dirk,
I'm using the GlazedListsSortModel no own implementation of ISortModel. And it's working until I call natTable.loadState(...)
I'll try to provide a small working example which reproduces my problem over the weekend. Should I post it here or better in another thread?
Re: Having problems to add sorting functionality [message #1446827 is a reply to message #1446643] Fri, 17 October 2014 11:16 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
You could try to check if one of the sortable examples have the DisplayPersistenceDialogCommandHandler registered and test if you can reproduce your issue there. Maybe one of the examples in Integration. Try to right click on the corner region and see if there is a context menu with an entry for dealing with states.
Re: Having problems to add sorting functionality [message #1448718 is a reply to message #1446827] Mon, 20 October 2014 10:40 Go to previous messageGo to next message
Kai Mechel is currently offline Kai MechelFriend
Messages: 6
Registered: July 2009
Junior Member
Hi,

I downloaded the sourcecode and grepped to find a matching example:
_810_SortableGroupByFilterColumnGroupAndFreezeExample.java
contains "loadState(...)".

The example saves my last state and loads it correctly. But it does not persist my own configurations, which I create in the "Manage view configurations" Dialog. My own saved configurations don't show up when I close the application and start it again... but the sorting works - seems like the loading behaves kind of strange here.

I downloaded the JNLP File and started it locally. 'myState.properties' are save beside the JNLP file and my own configurations do not show up in the file saved by the example code. Maybe that's why the sorting works in this example... but the example seems kind of broken, regarding user created/saved configurations.

Kind regards
Kai
Re: Having problems to add sorting functionality [message #1448728 is a reply to message #1448718] Mon, 20 October 2014 10:55 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
The "Manage view configurations" option only persists the state in memory. If you want to save those states in a file you need to add the appropriate functionality yourself. We haven't add that to the examples itself. So the example isn't broken, it only does what it should.

You are mixing things up. NatTable save/load states performs operations on a Properties instance. NatTable doesn't care where that instance comes from. You are talking about where the Properties instance comes from, a file or in memory.
Re: Having problems to add sorting functionality [message #1448742 is a reply to message #1448728] Mon, 20 October 2014 11:28 Go to previous messageGo to next message
Kai Mechel is currently offline Kai MechelFriend
Messages: 6
Registered: July 2009
Junior Member
I think I have to provide a small runnable example to show my problem, because it's not possible to reproduce it as requested in the previous posting, by using one of the examples that contain a 'DisplayPersistenceDialogCommandHandler'.
I tried to reproduce my problem with one of the sample apps in the NatTable Web Start Application. But since the examples don't seem to save the user configured state in the myState.properties file, that's not possible.

In my application, we use GlazedLists and save the NatTable's Properties to a file (which then contains the user entries with 'PREFIX.key=value' in addition to the '.key=value' default entries) , which we load when the applications starts again the next time. The loading of our previousley saved files, seems to break the sorting after we load them (loadState).

I'll get back as soon as I have a small standalone example class, which reproduces our problem.

[Updated on: Mon, 20 October 2014 11:29]

Report message to a moderator

Re: Having problems to add sorting functionality [message #1448765 is a reply to message #1448742] Mon, 20 October 2014 12:11 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Loading via DisplayPersistenceDialogCommandHandler should be the same as loading via properties file. Maybe you are trying to load prior natTable#configure()?

But ok, create some simple example to reproduce the issue.
Re: Having problems to add sorting functionality [message #1449465 is a reply to message #1448765] Tue, 21 October 2014 11:58 Go to previous message
Kai Mechel is currently offline Kai MechelFriend
Messages: 6
Registered: July 2009
Junior Member
That's it... a call to loadState() after configure() is working!

I was already adding the DisplayPersistenceDialogCommandHandler after configure(), because I read a comment somewhere in the examples...
... but I thought I have to load the state before the call to configure(), so that configure() can use theses infos. It did not come to my mind to move this call after configure. I was trying many other things, that seemed suspicous to me.

Thank you! Problem solved Smile

[Updated on: Wed, 22 October 2014 05:55]

Report message to a moderator

Previous Topic:Row selection + Cell editing facility in nattable
Next Topic:Customize Summary row
Goto Forum:
  


Current Time: Thu Apr 25 07:56:49 GMT 2024

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

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

Back to the top