Here you will find general information about configuring NatTable and the concepts involved.
This is a global object holding the following kinds of configuration
- Key bindings
- Mouse bindings
DisplayMode is a tag applied to a cell to identify the state the cell is in. Currently the following display modes are supported:
- Normal - The usual state
- Select - Signifies a cell is currently selected
- Edit - Signifies that the cell is being edited
Cell labels are a mechanism to tie configuration to specific cells. A cell label is a string/label which is attached to a cell.
- We might attach a label 'error' to cells which meet certain criteria. While painting all cells with the label 'error' will be painted red.
- We can attach a label 'checkbox' to all cell holding a boolean value. While painting all cells with the label 'checkbox' will be painted as a 'checkbox'.
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
The name of the region the cell is in is added as a default label. For example, all cells in the body region have the label BODY by default.
Layers and configuration objects
Configuration information is contributed by individual layers. When a layer is added to the stack it contributes relevant configuration via the AbstractLayer.addConfiguration() method. For example, when the SelectionLayer is added it contributes selection styling via the DefaultSelectionLayerConfiguration.
In order to contribute configuration information you need to:
- Implement the IConfiguration interface. It is usually easier to override one of the default configuration objects.
- Disable default configuration. This is done by setting 'autoconfigure' to false on the layer constructor. By default a layer will automatically add its default configuration.
- Add your configuration to the layer using the AbstractLayer.addConfiguration() method.
When the grid initializes it invokes your configuration object. At this point you can make entries in the IConfigRegistry and the UiBindingRegistry. These are global objects held by NatTable.