I need to set a custom style not for all, but some columns in a nattable. I can't set the configuration like this:
because this sets the configuration to the whole table. I have to override the configuration only to specific columns. In my case the columns should have the horizontal align set like this:
How can I achieve this? Thanks!
Best How To :
From NatTable styling docs
To enable conditional styling, the custom style needs to be registered in the IConfigRegistry against the label defined before.
Style style = new Style();
// You can set other attributes here
CellConfigAttributes.CELL_STYLE, // attribute to apply
style, // value of the attribute
DisplayMode.NORMAL, // apply during normal rendering
// apply for all cells with this label
To apply the CELL_LABEL label to your column follow the instructions from NatTable configuration docs
Attaching a label to a cell
Following the overall design convention, Layers can add labels to cells. In order to attach a label to a cell(s) you need to implement the IConfigLabelAccumulator interface. The IConfigLabelAccumulator.accumulateConfigLabels() is called on each layer. Every layer can add its labels to the LabelStack.
The most common use cases are available out of the box, including but not limited to:
CellOverrideLabelAccumulator - applies labels to cell(s) containing a specified data value ColumnOverrideLabelAccumulator - applies labels to all cells in a column You can make custom implementations for your own rules