Row and column tree
FastGrid documentation
To display row tree set
Tree attribute of the
Part and define tree level of the rows by
L attributes.
To display column tree set Cfg
ColTree attribute and define tree level of the columns by
L attributes.
Row / column level in tree.
-1 is not expandable root level without tree buttons,
0 is root expandable level, >=
1 are child expandable levels.
If the row / column has higher level than previous row / column (next for
ReversedTree), it is a
child row / column of the previous row / column.
In row the
L specifies also indent in
Tree column by
TreeWidth pixels.
The row / column children can be hidden / shown by collapsing / expanding the parent.
The row / column children are usually manipulated (moved / copied / deleted / hidden) with their parent.
Actions
IndentRow / IndentCol
(int target = 0, int level = 1, bits options = 0, bits hidden = 0)
OnClickIndent
Increases the actual or focused row / column
L by given
level. The
level can be negative.
Parameters
options and
hidden are the same as in
Indent.
It fails if not set
DraggingRows /
DraggingCols.
Actions
IndentRows / IndentCols
(int target = 0, int level = 1, bits options = 0, bits hidden = 0, int min = 0)
OnClickIndent
Increases the selected or focused rows / columns
L by given
level. The
level can be negative.
min - minimal count of the selected / focused rows / columns for the action success.
If min = 0 and target = 5 it returns false if the action modifies the same rows / columns as action HideRow / HideCol.
Parameters
options and
hidden are the same as in
Indent.
It fails if not set
DraggingRows /
DraggingCols.
Grid method Row / Col / Row[] / Col[]
Indent
(Row / Col / Row[] / Col[] src = null, int level = 1, bits options = 0, bits hidden = 0)
Increases the row / column
L by given
level. The
level can be negative.
The row / column is not changed if it has set
NoMove attribute except if set 3.bit of
options.
src specifies the row(s) / column(s) that are deleted / undeleted / removed.
It can be one Row or Col object or array of Row or Col objects - all the objects must be from the same grid and of the same kind (Row or Col).
options specifies various options, bit array:
1.bit | &1 | = 1 - saves changes, sets the row / column as moved. |
2.bit | &2 | = 2 - reserved |
3.bit | &4 | = 4 - ignores NoMove, changes the L regardless on the permission. |
4.bit | &8 | = 8 - without children, modifies only given items, without their child rows / columns. |
5.bit | &16 | = 16 - without Block, modifies only given items, not all items with the same Block. |
6.bit | &32 | = 32 - only visible, but still modifies collapsed children if not set with 8. |
hidden specifies what to do if new parent is collapsed, hidden or deleted: , bit array:
1.,2.bit | &3 | If new parent is collapsed: 0 - restrict change, 1 - expand the parent, 2 - hide the modified row / column, 3 - ignore - permit the change and do nothing.
If outdents collapsed row / column and it gets more children, it is expanded for values 1 and 2.
|
3.,4.bit | &12 | If new parent is hidden: 0 - restrict change, 4 - show the parent, 8 - hide the modified row / column, 12 - ignore - permit the change and do nothing. |
5.,6.bit | &48 | If new parent is deleted: 0 - restrict change, 16 - undelete the parent, 32 - delete the modified row / column, 48 - ignore - permit the change and do nothing. |
Returns modified Row or Col (for
src = object) or array of modified Rows / Cols (for
src = array).
Or returns null if no rows / columns were modified.
API event bool
OnIndent
(Grid grid, Row[] / Col[] items, int level, bool test)
Called before row(s) or column(s) in
items have increased the
L attribute by given
level. Called from
Indent method.
test is true if just testing possibility of changing, e.g. to display the action in popup menu.
Return true to cancel the action.
The event handler can modify the
items to indent different row(s) / column(s).
API event void
OnIndented
(Grid grid, Row[] / Col[] items, int level)
Called after row(s) or column(s) in
items have increased the
L attribute by given
level. Called from
Indent method.
If the row and column tree is reversed like default tree in MS Excel.
1.bit &
1 =
0 - row children are below their parent.
1 - row children are above their parent.
2.bit &
2 =
0 - column children are right to their parent.
2 - column children are left to their parent.
3.bit &
4 =
4 - if set and the row tree in data is in different direction, the rows will be reversed to satisfy the first bit.
4.bit &
8 =
8 - if set and the column tree in data is in different direction, the columns will be reversed to satisfy the second bit.
Grid method bool
SetReversedTree
(int value)
Sets
ReversedTree to the
value.
Returns true on change, false without change.
Moves the rows / columns to satisfy the order, like if if set
ReversedTree&
12.
API event bool
OnSetReversedTree
(Grid grid, bits reversedtree)
Called before
ReversedTree changed to
reversedtree. Called from
SetReversedTree method.
Return true to suppress the change.
API event void
OnReversedTree
(Grid grid, bits changed)
Called after rows / columns order changed due change of
ReversedTree. Called from
SetReversedTree method.
changed &
1 - changed rows, &
2 - changed columns.
If and how displays count of children in the expand icon.
-1 does not display digits, displays only plus.
>=
0 displays digits as count of collapsed children, bit array:
&
1 = only visible (ignores filtered and manually hidden),
&
2 = only expanded (ignores children of collapsed parent, except the immediate),
&
4 = only immediate (children directly in the parent),
&
8 = only leaf (items without children).
Row tree
Row tree is displayed in row cells in one column. The column can be different per row part or even per row.
If and where the row tree is displayed.
0 - Row tree is not displayed. Existing row
L attributes are ignored.
1 - Row tree is displayed in one column per part set by
part Tree attribute. If part has not
Tree attribute, the tree is not shown, but row's
L attribute is still used.
2 - Row tree can be displayed in different column in every row by
row Tree attribute. If row has not
Tree attribute, the part
Tree is used.
It can slow down the row manipulation, especially adding many new rows!
The RowTree cannot be changed by API, it is only possible to just hide / show the row tree by setting the part Tree or row Tree attribute.
Column id where to display row tree lines and expand / collapse buttons in the part. Used only if set
RowTree >=
1.
Grid method bool
SetTree
(string part, string / Col col)
Sets
part Tree attribute to
col.
Returns true for change, false for no change and null for error.
Grid method bool
HasRowTree
( )
Returns true if the grid shows row tree.
Grid method Col
GetTreeCol
(Row row)
Returns column where the row shows its row tree or null.
Column id where to display row tree lines and expand / collapse buttons in the row. Used only if set
RowTree =
2.
If not set, the part
Tree attribute is used.
It is strongly recommended to display the same level (L value) always in the same column, otherwise the levels relation will be confusing for users.
If set, it displays buttons for expanding individual row levels in this row in the part
Tree column.
It is usually set in
Header row as
LevelsPart = "
Body" to display buttons for expanding levels in Body.
It can contain one part id or array or comma separated string of the part ids.
The row can control also its own row part.
For
RowTree =
2, to specify also column where to display the buttons for the column, add it with "$" as suffix to the part.
For example
LevelsPart = "Body,Body$Col1,Body$Col4,Foot$Col2".
If and how will be displayed the vertical tree lines.
3 - shows vertical and horizontal lines in tree plus cross line from button to children line and hides the root tree (on
L = 0) in rows without children.
2 - shows vertical and horizontal lines in tree plus cross line from button to children line.
1 - shows vertical and horizontal lines in tree.
0 - hides the lines in tree, shows only expand / collapse icons.
-1 - hides the lines in tree, shows only expand / collapse icons. Leaf child rows (without icon Expand / Collapse) are shown on the same level as their parent.
Indent in
Tree cell per one level in pixels. Minimal value for normal display with tree lines or
LevelsPart buttons is
7.
Space in
Tree cell between left cell edge and tree line / icon.
Space in
Tree cell between tree icon and cell text (added to cell's
PaddingLeft).
If
TreeWidth is less or equal to this value, the
LevelsPart buttons are displayed narrow.
1. bit &
1 - if set,
Levels button collapses all levels, otherwise it collapses only actual level.
Column tree
Column tree is displayed in special
row Part Type="
Tree". There can be more such parts in grid, to display tree for different column sets.
If shows column tree in
row Part Type="
Tree".
By default there is defined one
row Part { id:"Tree", Type:"Tree", Add:1 } in
RowParts above header, below to top toolbar. But the ColTree is set to 0 to disable the column tree by default.
The ColTree cannot be changed by API, it is only possible to just hide / show the column tree by setting the part Hidden attribute.
Grid method bool
HasColTree
( )
Returns true if the grid shows column tree.
Vertical direction of the
row Part Type="
Tree", bit array:
1.bit &
1 - vertical lines go from bottom to top.
2.bit &
2 - order of rows is reversed, the first row starts bottom.
If set, adds one empty row bottom the
row Part Type="
Tree" to display one more Levels button to expand all columns, including last level.
Default value is
0, but the default
row Part id="
Tree" has set Add =
1.
ColSet id its tree is displayed in this
row Part Type="
Tree".
The columns for the ColSet are defined in
{Part id}${Set id}
If set to column, it displays buttons for expanding individual column levels in this column in the Tree part for given column parts.
If set to column or cell, it displays buttons for expanding individual column levels in this cell for given column parts, if the cell have set also
RightIcons = "
ColLevels".
It is usually set in
Index column as
LevelsPart = "
Cols" to display buttons for expanding column levels in Cols.
It can contain one part id or array or comma separated string of the part ids.
The column can control also its own column part.
If the lines will be displayed in column tree.
0 - hidden; displayed are only expand / collapse icons.
1 - shown for expanded columns; for collapsed column is shown only expand icon.
2 - shown for both collapsed and expanded columns; for collapsed column is shown line just for the column width.
Height of one row in column tree part, in pixels.
Minimal reasonable value is
5.
Space above the first row in the column tree part, in pixels.
Space below the last row in the column tree part, in pixels.
Space between column left edge and the expand / collapse icon, in pixels.
If set to
null, the icon is centered in the column width.
Space between column right edge and the tree vertical line.
If set to
null, the line is centered in the column width.
If
ColTreeHeight is less or equal this value, the levels buttons are displayed narrow.
If
ColTreeHeight is less or equal this value, the levels buttons are displayed in two columns shifted by
ColLevelsShiftWidth.
Shift of the levels buttons in pixels if displayed in two columns due
ColLevelsShift.
Alignment of the levels buttons inside its column,
0 - left,
1 - right,
2 - center.
Comma separated list or array of row ids, one for every column level. These rows are shown or hidden on expand or collapse particular column level. The rows are shown/hidden only if the first row is visible.
Expand & collapse
If the row or column is collapsed (hides its children).
If set, the row / column cannot be expanded / collapsed (cannot show / hide its children).
If set, collapses all tree levels under this value and expands all levels higher or equal to this value. On grid start and on grouping change.
The rows / columns are expanded / collapsed up to given
level.
Rows / columns with
L less than
level are expanded (show their children).
Rows / columns with
L higher or equal than
level are collapsed (hide their children).
level =
-1 expands all rows / columns.
level =
0 collapses all rows / columns.
level =
-2 expands all except the last level,
-3 expands all except two last levels, ...
It highlights appropriate
LevelsPart button.
For
RowTree =
2 it can be an object as values for individual Tree column ids, e.g.
CollapseLevel:{Col1:2,Col7:-1}.
It can be set to number to use instead of row / column
L when collapsing / expanding all rows / column on given level or Part
CollapseLevel.
It can be set negative, to be calculated from right, from maximal level-1.
For example if set to
-1, the row / column will be expanded and its children will be shown when expanding only the last level.
All rows / columns in the same parent should have the same value of the CollapseLevel.
Cfg string[]
CollapsedRows
Array or comma separated string of ids of rows that will be collapsed on start.
If CollapsedRows are defined more times in the input data, they are joined together, except if the first item is "-".
Cfg string[]
ExpandedRows
Array or comma separated string of ids of rows that will be expanded on start.
If ExpandedRows are defined more times in the input data, they are joined together, except if the first item is "-".
Cfg string[]
CollapsedCols
Array or comma separated string of ids of rows that will be collapsed on start.
If CollapsedCols are defined more times in the input data, they are joined together, except if the first item is "-".
Cfg string[]
ExpandedCols
Array or comma separated string of ids of rows that will be expanded on start.
If ExpandedCols are defined more times in the input data, they are joined together, except if the first item is "-".
Actions
CollapseRow / CollapseCol
(int target = 0, int collapse = null, int levels = null)
OnClickCollapseRow/Col, OnClickCollapse
Expands or collapses actual or focused row / column.
Parameters
collapse and
levels are the same as in
Collapse.
Actions
CollapseRows / CollapseCols
(int target = 0, int collapse = null, int levels = null, int min = 0)
OnClickCollapse
Expands or collapses selected or focused rows / columns.
min - minimal count of the selected / focused rows / columns for the action success.
If min = 0 and target = 5 it returns false if the action modifies the same rows / columns as action CollapseRow / CollapseCol.
Parameters
collapse and
levels are the same as in
Collapse.
Actions
CollapseAllRows / CollapseAllCols
(int target = 0, int level = 0, int min = 0)
OnClickCollapse
Expands or collapses all rows / columns in grid.
min - minimal count of the rows / columns that can be expanded / collapsed for the action success.
The rows / columns are expanded up to given
level.
Rows / columns with
L less than
level are expanded (show their children).
Rows / columns with
L higher or equal than
level are collapsed (hide their children).
level =
-1 expands all rows / columns.
level =
0 collapses all rows / columns.
Actions
CollapseLevel
(int target = 0)
OnClickCollapseRowLevel, OnClickCollapseColLevel
Special action that expands / collapses rows / columns up to level according to the clicked level button.
This action can be assigned only to OnClickCollapseRowLevel and OnClickCollapseColLevel events.
Grid method Row / Col / Row[] / Col[]
Collapse
(Row / Col / Row[] / Col[] src, int collapse = null, bits options = 0, int levels = null)
Expands or collapses given row(s) or column(s).
src specifies the parent row(s) / column(s) that are expanded / collapsed. It can be one Row or Col object or array of Row or Col objects - all the objects must be from the same grid and of the same kind (Row or Col).
collapse =
1 - collapse,
0 - expand,
null - change the collapsed state (according to the first row / column collapsed state).
options specifies various options, bit array:
1.bit | &1 | = 1 saves changes. |
2.bit | &2 | = 2 preserves the first expanded row under mouse for set ReversedTree. |
3.bit | &4 | = 4 - ignores NoCollapse, expands / collapses all given items regardless on the permission. |
If set
levels, expands / collapses given number of levels deep. For
-1 expands /collapses all levels of given rows / columns. For
null expands / collapses one level.
Returns expanded / collapsed Row or Col (for
src = object) or array of expanded / collapsed Rows / Cols (for
src = array).
Or returns null if no rows / columns were modified.
Grid method bool
IsCollapsed
(Row / Col src)
Returns 1 if the row / column is collapsed (hides its children).
If the child is hidden due collapsed parent is possible to find out by
IsHidden, 3.bit (&
4).
Grid method bool
CollapseAll
(int level, bool cols = 0, bits options = 0)
Expands or collapses all rows (
cols =
0) / columns (
cols =
1) in grid.
The rows / columns are expanded / collapsed up to given
level.
Rows / columns with
L less than
level are expanded (show their children).
Rows / columns with
L higher or equal than
level are collapsed (hide their children).
level =
-1 expands all rows / columns.
level =
0 collapses all rows / columns.
level =
-2 expands all except the last level,
-3 expands all except two last levels, ...
options specifies various options, bit array:
1.bit | &1 | = 1 saves changes. |
6.bit | &32 | = 32 - ignores NoCollapse, expands / collapses all given items regardless on the permission. |
Returns true if some row / column collapsed state was changed, otherwise false.
It can be run asynchrounsly when applied SyncRows.
Grid method bool
ExpandParents
(Row / Col src)
Expands all parents of the row / column to make the row visible.
Returns true if some row / column collapsed state was changed, otherwise false.
API event bool
OnCollapse
(Grid grid, Row[] / Col[] items, int collapse, bool all, bool test)
Called before row(s) or column(s) in
items are expanded / collapsed. Called from
Collapse (
all =
0) or
CollapseAll (
all =
1) method.
collapse =
0 - expand,
1 - collapse.
test is true if just testing possibility of expanding / collapsing, e.g. to display the action in popup menu.
Return true to cancel the action.
The event handler can modify the
items to expand / collapse different row(s) / column(s).
API event void
OnCollapsed
(Grid grid, Row[] / Col[] items, int exp, bool all)
Called after row(s) or column(s) in
items are expanded / collapsed, but before Paint. Called from
Collapse (
all =
0) or
CollapseAll (
all =
1) method.
collapse =
0 - expand,
1 - collapse.