No we do not support CSS styling in NatTable at the moment. There is an open feature request to add that support.
What do you need to add CSS support? Well I guess you need an engine that is able to read a CSS file and translates it into NatTable styles. You would also need to specify NatTable specific styles like for example the eclipse or JavaFX styles. And there needs to be a way to put those styles into the NatTable ConfigRegistry.
We provide sponsored developments if you are interested.
So, one option is that we use something like CSS engine for getting styles from CSS file and set the colors/styles in TableStyle. But in this case, we will have to recreate the table if CSS values are changed at runtime? ,because TableStyle is applied once during the creation of the table..
I am already applying dynamic styling to rows and columns by registering config attributes at runtime based on labels.
But, my concern is to change those styles that we specify in TableStyles like tableStyle.evenRowCellSelectionBgColor etc.. This technique hide the internal complexities of dealing with configurations. For example at runtime I want to do something like
If you are using the NatTable even/odd row coloring than you do! Even if you don't know it.
Everything in NatTable is configured via ConfigRegistry! There is no way around it!
The color for the even row is an attribute of the style that is registered for the EVEN_ROW_CONFIG_TYPE label. If you have a reference to that style you should be able to change the value of the attribute at runtime. Maybe you need to refresh after the change.
So now I am done with the part of creating the configurations and adding them
Get styles -> create configurations -> addConfiguration
But now I want to take it one level above. In css we define an element for each control, for example in css I say set background color of all composites to black, thats it and we don't need to do anything else and application itself appky style to all the composites.
But in case of nattable we will have to apply configurations manually.
Read CSS -> MISSING PART -> create configurations -> addConfiguration
I am confused about the above missing part. I need to do something like this
I want to listen to theme change event of the eclipse application in which my nattable is embedded. Every time theme is changed I need to create and load new configurations for the nattable based on the CSS styles. What is the proper way to do this?
Ah ok ... you don't need to create new configurations. You should modify the existing configurations by registering/unregistering config attributes in the ConfigRegistry at runtime as I suggested some posts ago.
So you need to hold the reference to your ConfigRegistry and operate on it on theme switches.