Basic concepts
NatTable is more than just a table. It is a general framework to create flexible and highly customizable grids. It is necessary to understand some general concepts to configure and use NatTable.
Virtual table
Layers
A layer is NatTable's way of adding functionality. Each feature usually is implemented by a separate layer. For example column hiding is implemented by the ColumnHideShow layer, Sorting is implemented by the SortHeaderLayer and so on. Layers can be arranged in 'stacks', by piling them on top of each other. At the bottom of each layer stack there should be a DataLayer which serves as a data source for all other layers.
For a list of available layers you can have a look here.
![NatTable Architecture](images/NatTable_Architecture.png)
The above diagram shows the architecture of a NatTable that is build as a grid with several layers.
Regions
Configuration
For every NatTable instance the configuration information is held in the following registries:
- ConfigRegistry
- UiBindingRegistry
Every layer has configuration information associated with it. This is in the form of IConfiguration objects. When the NatTable starts up every layer is given the opportunity to configure itself and make entries in the ConfigRegistry and the UiBindingRegistry. Mainly the following aspects are affected by configuration:
![Simplified NatTable configuration UML](images/NatTable_Configuration_UML_simplified.png)
The above simplified UML diagram shows the relationship regarding configuration on the NatTable and its layers.
Actions/Commands/Events
For handling user interaction with the NatTable, actions of type IKeyAction, IMouseAction or IDragMode can be registered on UI interactions (see here). Normally these actions will then fire a Command on the NatTable to invoke some behaviour. Commands are passed down the layer stack until a layer handles the Command and stops further propagation. A layer can handle a Command by special handling within the layer itself or on registering the corresponding command handler to the layer. Executing actions on the NatTable programmatically is also achieved by firing Commands on the NatTable.
After a Command is executed, normally the state and therefore the UI needs to refreshed or at least the layers need to be informed about the changed state. For this an event mechanism is used within the NatTable. Typically once a command is handled by a layer, the layer will fire an event to indicate that a change has occurred. Anyone can register themselves as a listener to layer events by implementing the ILayerListener interface.
Note that commands travel down the layer stack and normally will be consumed on handling, while events travel up the layer stack informing every listener whether handled or not.
For further information have a look here.
![NatTable Commands/Events](images/NatTable_Commands_Events.png)
![NatTable system diagram](images/NatTableSystemDiagram.png)