Creating Hierarchical DataGrids
The DataGrid enables a hierarchical arrangement of rows and columns so that specific hierarchy levels can be hidden or displayed.
For example, to display a CInputFieldas a popin, you can expand a hierarchy tree.
The properties relevant for displaying the hierarchy are available in the DataGridCell. The DataGridCell has event onHierarchyChange, which is triggered when a cell is selected for which a hierarchyState is defined.
The following conditions must be met:
- The number of columns within a DataGridSegmentColumn must be the same across all DataGridSegments.
- The number of rows within a DataGridSegmentRow must be the same across all DataGridSegments.
To insert and delete data in two-dimensional context nodes, the following service operations are provided:
node->insert_columns( from_x = from_x num_cols = num_cols ). node->remove_columns( from_x = from_x num_cols = num_cols ). node->insert_rows( from_y = from_y num_rows = num_rows ). node->remove_rows( from_y = from_y num_rows = num_rows ).
The data does not have to be reloaded by the application.
To react to onHierarchyChange events in your application, follow the steps below:
- Change the value of property hierarchyState of DataGridCell.
- Insert rows and columns for all segments of the relevant DataGridSegmentRow or DataGridSegmentColumn into the two-dimensional context node.
- Reload additional data into the two-dimensional context node.
- Insert additional rows or columns as height or width information into the context nodes that are bound to the DataGridSegmentRows or DataGridSegmentColumns.
You can find an example in component WDR_TEST_DATA_GRID in view TC_HIERARCHY.