TreeGrid Tree Tutorial
2. Column tree
Expanding and collapsing columns and optionally also rows
-
Column tree
is done by simply showing and hiding listed columns. There is no limit in column count or levels.
The columns in tree, unlike row tree, are not nested and are defined normally like without the tree.
The tree is simply defined by Expand button in some cell (usually, but not necessary, in Header) and list of columns to hide / show them on click to this button.
To be the expanding fast, you should not change default setting of Cfg attribute FastColumns='1'.
The initially hidden column should have set both Visible
='0' and Hidden
='1' to be rendered on grid start as hidden column and the expanding will be fast.
-
For column tree define
Button
='Expand' or Icon
='Expand' in cell in grid, usually in Header cell.
And define ExpandCols
as list of columns to show or hide on click to the button.
The Expand button will be marked as expanded, if any of the columns in ExpandCols will be shown.
In more complex cases you can define cell Expanded
attribute to preset the expanded state of the Expand button. It should be related to the visibility of the ExpandCols columns.
The expanded columns don't need to be adjacent, nor in the same section. They should be adjacent only if some cells are spanned among them.
-
More Expand buttons can control the same column.
In this case set the column attribute ExpandLevel
to specify how many Expand buttons will need to be expanded to show the column (and collapsed to hide the columns).
Every expanding of button increase ExpandLevel of all columns in its ExpandCols list and every collapsing of the button decreases ExpandLevel of the columns.
The column is shown if its ExpandLevel is positive (higher than 0).
The column is hidden if its ExpandLevel is zero or negative (less or equal to 0).
The ExpandLevel must be set accordingly to initial Expanded state of the buttons and visibility of the column.
For example you have two buttons expanding one column, the column settings can be:
-
ExpandLevel='-1' Visible='0' - both the buttons must be expanded to show the column
-
ExpandLevel='0' Visible='0' - at least one button must be expanded to show the column
-
ExpandLevel='1' Visible='1' - at least one button must be collapsed to hide the column (visible state of the ExpandLevel='-1')
-
ExpandLevel='2' Visible='1' - both the buttons must be collapsed to hide the column (visible state of the ExpandLevel='0')
Remember, there is no limit in count of buttons expanding the same column and also more columns can be expanded by one button, so there are unlimited combinations for expanding.
-
Row tree
- it is possible also to control visibility of any rows similarly to the columns behavior described above.
The row list is defined by ExpandRows
.
It is possible to define both ExpandCols and ExpandRows for one Expand button, usually to show next (Header) row with next Expand buttons for next column level(s).
Remember, this row tree type is intended as support for the column tree. For standard row tree use rather the MainCol and nested rows or grouping feature, because it is much faster and support many next features.
-
There are also provided actions to expand/collapse one cell (ExpandCell) and all Header cells (ExpandAllCells,CollapseAllCells).
There are also API methods to expand / collapse given cell (ExpandCell) and to check the expanded state of the cell (IsCellExpanded).