Configuring NatTable

A quick overview of some of the concepts involved..

Config registry

This is a global object holding the following kinds of configuration

  1. Cell styling and painting
  2. Editing rules and validators
  3. Comparators for sorting
  4. Any piece of arbitary information can be stored in this registry.

UI binding registry

This is a global object holding the following kinds of configuration

  1. Key bindings
  2. Mouse bindings

Display mode

Display mode is a tag applied to a cell to identify the state the cell is in. Currently the following display modes are supported:

  1. Normal - The usual state
  2. Select - Signifies a cell is curently selected
  3. Edit - Signifies that the cell is being edited

For example, a cell might be colored white in normal mode but a gray color might be applied to it when it is in select mode

Cell labels

Cell labels are a mechanism to tie configuration to specific cells. A cell label is a string/label which is attached to a cell.
For example,
- 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:

  1. Implement the IConfigLabelAccumulator interface. This 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.
    1. CellOverrideLabelAccumulator - applies labels to cell(s) containing a specified data value
    2. ColumnOverrideLabelAccumulator - applies labels to all cells in a column
    3. You can make custom implementations for your own rules

Default labels

The name of the region the cell is in is added as a default label. For example, all cells in the body 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.addConfiguartion() method. For example, when the SelectionLayer is added it contributes selection styling via the DefaultSelectionLayerConfiguration.

In order to contribute configuration information you need to:

  1. Implement the IConfiguration interface. It is usually easier to override one of the default configuration objects.
  2. 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.
  3. Add your configuration to the layer using the AbstractLayer.addConfiguartion() 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.