Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » How to remove configuration from Nattable?(Dynamic column number - user can select more or less columns to display)
How to remove configuration from Nattable? [message #1756131] Sun, 12 March 2017 20:12 Go to next message
Maximus X is currently offline Maximus XFriend
Messages: 6
Registered: March 2017
Junior Member
Hi,
I'm stuck on the following issue, hoping that someone has some advice.
I got a table where the number of columns is dynamic, the user can select columns for display, adding some in the front, or others in the back.

The issue is, some of the columns have configuration registered on them to turn them editable/format their styling.
I do it through
natTable.addConfiguration(new myConfigClass());
natTable.configure();

which I also call on a columns update.


I noticed that configuration keeps piling up, and columns keep their old styling. What would be the right approach to deal with this, preferably with a code example.
Re: How to remove configuration from Nattable? [message #1756276 is a reply to message #1756131] Tue, 14 March 2017 19:28 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2624
Registered: July 2012
Senior Member
Quote:
I do it through
natTable.addConfiguration(new myConfigClass());
natTable.configure();

which I also call on a columns update.


This is actually not correct according to the NatTable principles. NatTable#configure() should only be called once for the initial configuration. If you need to change configuration values at runtime, you need to directly operate on the ConfigRegistry that you can retrieve via NatTable#getConfigRegistry().

From your explanation I'm not sure if you are familiar with the configuration concepts in NatTable. We have a label based mechanism to separate configurations from structures. In the end this means you need to figure out how to create an IConfigLabelAccumulator that applies labels to your structure according to your requirements/settings in the table. That means actually you only need to register the configurations once for special labels, e.g. "editable" in case you configure your dynamic column to be editable.

How to implement your IConfigLabelAccumulator based on your structure I can't tell. That is very specific to your dynamic data model. But I don't see a reason for dynamically registering and unregistering configurations from what you explained.
Re: How to remove configuration from Nattable? [message #1758637 is a reply to message #1756276] Thu, 30 March 2017 21:57 Go to previous messageGo to next message
Maximus X is currently offline Maximus XFriend
Messages: 6
Registered: March 2017
Junior Member
Thanks for the thorough explanation Dirk, I ended up rebuilding the entire table on a column change instead and that worked for me.
Re: How to remove configuration from Nattable? [message #1758648 is a reply to message #1758637] Fri, 31 March 2017 06:31 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2624
Registered: July 2012
Senior Member
Quote:
I ended up rebuilding the entire table on a column change


If that works for you, fine. Dependent on the data model this is probably the most efficient way.

Alternatively you could write a method that dynamically adds and removes configurations from the IConfigRegistry. The necessary methods are available there. I would typically try to do it this way, but as I said before, that depends on the data model and the logic you used for cell labeling.
Previous Topic:NatTable 1.5.0 released
Next Topic:Icons will not be displayes when column is frozen
Goto Forum:
  


Current Time: Mon Nov 19 00:44:43 GMT 2018

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

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

Back to the top