TreeGrid v6.0
Master – detail grids
TreeGrid supports master / detail relationship as showing (master) row’s children in different (detail) grid.
To define master / detail relationship, set <Cfg Detail=’1’ id=’DetailGridId’/> in detail grid and <I Detail=’DetailGridId’/> in master rows in master grid.
It is also possible to have a cascade of more related grids (detail grid can also be a master for another grid).
It is also possible to have one master grid with more detail grids or more master grids with one or more detail grids.
The master grid contains all data and only master grid can upload changes to server.
Every master row (with Detail attribute) contains children that will be displayed in detail grid when the master row is chosen.
The detail children in master grid can be also created automatically by defining them as children of default row (<D>).
It is useful in creating master / detail relation for plain tables, where are the source data defined only once in the master root rows.
The detail grid contains only layout to define columns and fixed rows, but no variable data rows.
It is used to show and edit children of master row from master grid.
You can define data rows in detail grid to be displayed when it is empty - when does not display any master row’s children.
It is possible to have completely different layout in detail grid than in master grid, use CopyTo attribute to provide correct relation between cells.
For more information see Master / detail tutorial.
The way of master/detail relationship
The children (as in tree) of master row are displayed after focus/click/double click/expand in detail grid.
The children are still part of master grid’s data and are downloaded / uploaded by master grid.
For the detail grid you need to specify the layout with empty data or with user row displayed when no data is shown in detail grid.
The layout of detail grid does not need to be the same as of master grid; you can add or hide other columns, but remember, uploading is done by master grid and only its columns are uploaded.
The rows can be dragged between master and detail grid.
One master grid can have more detail grids and one detail grid can have more master grids, but only one at a time.
The master and also detail grid can show data in tree, you can specify by Detail attribute which rows are shown as detail.
For classic master-detail relationship without tree you should specify MainCol=’’ and all master rows set Expanded=’0’.
You can also use CopyTo attribute if you have editable cell in master row linked to cell in detail.
<I> string[ ] Detail Master row attribute upd 7.0 .
It is the main attribute for master / detail relationship.
Set it to id of detail grid where will be displayed the row’s children. This means that every master row can be displayed in different detail grid.
Since 7.0 it can contain more ids, comma separated, to display the row’s children in more detail grids.
<Cfg> string[] MasterDef Detail grid attribute new 7.0 .
Comma separated list of default row names that can be displayed in this detail grid.
Only rows their Def attribute is listed in the MasterDef are displayed in this grid.
Useful when displaying one master row in more detail grids or displaying master / detail in tree with normal children.
<Cfg> int DetailRowsVisible [3] Detail grid attribute new 7.0 .
If the rows that are hidden in master grid will be shown in detail grid. Does not affect deleted rows.
0 – never
1 – only rows hidden by filter
2 – all hidden rows
3 – all hidden rows and all the rows will get also CanFilter=1
<Cfg> bool Detail [0] Detail grid attribute .
Set it to true for grid used as detail grid.
It is just support attribute to behave the detail grid slightly different – to not let users to add or drag rows into empty detail grid.
<Cfg> int DetailOn [1] Master grid attribute .
Master grid attribute. When to show data in detail grid.
0 – disabled, 1 – on focus to row, 2 – on click to row, 3 – on double click to row.
For more options you can attach ShowDetail action to events like OnFocus, OnClickCel or OnDblClickCell.
<Cfg> int DetailExpand [0] Master grid attribute .
What to do when expanding master row.
0 – show children in detail grid only
1 – expand the row only - the children will be visible only in master grid. The DetailOn should be 0 or 3.
2 – show children in detail grid and also expand the row – the children will be on two places in two copies and changes will be done to both.
<D> int AddDefChildren [1] Master grid attribute new 7.0 .
When the child rows defined in default (the <D> <I/><I/>... </D>) will be added to all rows using the given default.
0 – only when adding new rows with the default
1 – also on start to all rows without children
2 – also on start to all rows. If the row has children, the new children will be added before them
3 – also on start to all rows. If the row has children, the new children will be added after them
<cell> string[] CopyTo Master cell attribute .
List of cells where to copy this value after it is changed.
It is comma separated list: row1,col1,row2,col2,... row is row id, col is column name
row can also be these special words:
Parent – parent row, Next – next sibling, Prev – previous sibling, Children – all children
Children_X – All children with specified default as X
Child_X – specific child, if X is number, it means child on specified position (from 0), if X is string it means the first child with specified default (Def attribute).
Sibling_X – specific sibling, it is the same as Child_X, but relative to parent row and not to this row.
Used usually in master / detail relationship to copy (detail) children cells to master row cells and vice versa.
Cross references are permitted, because the copying is applied only if value is changed to different value.
API event bool OnShowDetail (TGrid master, TGrid detail, TRow row) .
Called before master row’s children are displayed in detail grid, can return true to suppress action
API event void OnShowDetailFinish (TGrid master, TGrid detail, TRow row) .
Called after master row’s children are displayed in detail grid.
API method void ShowDetail (TRow row, string detail_grid_id) .
Shows the master row’s children in the given detail grid.
API method void RefreshDetail (TGrid grid, bool clear) .
Refreshes the given detail grid according to its actual master row’s children.
If grid is null, refreshes all detail grids on page.
Refreshes only actually loaded detail grids – grids that have actually attached its master row.
If clear is true, clears the grid and removes the relation to the current master row.
<Actions> ShowDetail ...F Not attached to any event, master grid action .
Shows data in detail grid for actual or focused row. It fails, if details grid already shows data for given row or the row is not master row.
This action is not attached to any event by default, because showing detail grid is controlled by DetailOn attribute.
<Actions> RefreshDetail ...F Not attached to any event, master grid action .
Shows or refreshes data in detail grid for actual or focused row. It fails, if the row is not master row.
<Actions> ClearDetail ...F Not attached to any event, master grid action .
Clears detail grid for actual or focused row. It fails, if the row is not master row.