Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Mark same column values by the same color
Mark same column values by the same color [message #964045] Tue, 30 October 2012 08:05 Go to next message
Michi Classen is currently offline Michi ClassenFriend
Messages: 36
Registered: March 2012
Member
Does NatTable provide a functionality to mark the same column values with the same color?

E.g.
|rabbit|
|pig|
|rabbit|
|crocodile|
|pig|
...

This function will be turned off/on, therefore the marking is done by an activated command/handler.
Re: Mark same column values by the same color [message #964092 is a reply to message #964045] Tue, 30 October 2012 08:51 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 1434
Registered: July 2012
Senior Member
Hi,

yes this can be achieved by attaching labels to the cells dependent on your cell values. Have a look at the styling documentation, the conditional styling chapter: http://eclipse.org/nattable/documentation.php?page=styling

If you want to connect the activation for the conditional styling to a command, you should think about having some kind of flag that is also evaluated by your IConfigLabelAccumulator. And on toggling the state of your flag, you should refresh the table.

Greez,
Dirk
Re: Mark same column values by the same color [message #965781 is a reply to message #964092] Wed, 31 October 2012 13:54 Go to previous messageGo to next message
Michi Classen is currently offline Michi ClassenFriend
Messages: 36
Registered: March 2012
Member
Thanks Dirk Smile

Everything works fine. I will publish the solution for interested developers, when I have time.
Re: Mark same column values by the same color [message #965784 is a reply to message #965781] Wed, 31 October 2012 13:59 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 1434
Registered: July 2012
Senior Member
Nice to hear that it works. Smile

Yes it would be great to have such "how to ..." facts. If you like, I can then also push them to our FAQ section of our documentation. Up to you.
Re: Mark same column values by the same color [message #985670 is a reply to message #965784] Thu, 15 November 2012 16:16 Go to previous messageGo to next message
Michi Classen is currently offline Michi ClassenFriend
Messages: 36
Registered: March 2012
Member
Is it possible to set the backing data value of a cell explicitly, which is different to the display value?
Re: Mark same column values by the same color [message #985672 is a reply to message #965784] Thu, 15 November 2012 16:21 Go to previous messageGo to next message
Michi Classen is currently offline Michi ClassenFriend
Messages: 36
Registered: March 2012
Member
Is it possible to set the backing data value of a cell explicitly, which is different to the display value?

This is necessary to hightlight those columns only, which have the same backing data value, e.g.

E.g.
|animal | backing data value|
=========================
|rabbit | r1 |
|pig | p1 |
|rabbit | r1 |
|crocodile| c1 |
|pig | p2 |
...

In this case the text 'pig' in row 2 and 5 isn't marked by the same color.

[Updated on: Thu, 15 November 2012 16:34]

Report message to a moderator

Re: Mark same column values by the same color [message #985787 is a reply to message #985672] Fri, 16 November 2012 08:04 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 1434
Registered: July 2012
Senior Member
I'm not quite sure what you are trying to do. But here's what I think would be the solution you are asking for.

As explained in the documentation, you can do conditional styling in several ways. http://eclipse.org/nattable/documentation.php?page=styling

You have to think of the CellOverrideLabelAccumulator, ColumnOverrideLabelAccumulator and RowOverrideLabelAccumulator as convenience label overriders, as they can be used for the most common cases where styles should be applied because of the cell content.

If you need a solution that interprets other values than the shown value for styling, you should create your own IConfigLabelAccumulator that knows the data provider or whatever is needed to get your backing data. Usually this data is also available within the objects you are showing, but you can also think of another datastore that holds that data. This depends on your architecture.

You will also find an example for this in the examples that are added to the articles written about NatTable.

I hope this answers your question,
Dirk
Previous Topic:Default Nattable, how to edit a cell
Next Topic:Moving rows in NatTable when its in sorted state
Goto Forum:
  


Current Time: Mon Dec 22 03:32:37 GMT 2014

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

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