TreeGrid v6.0
Row adding and copying
Only variable rows can be added or copied.
Fixed (Head and Foot) and Space rows cannot be added or copied.
Adding new empty row
New empty row can be added by actions AddRow, AddChild and other Add... actions. These actions are usually attached to Toolbar Add and AddChild Button and also to CopyMenu menu.
By API can be new row added by AddRow method.
Copying existing row
Existing row can be copied by actions CopyRow, CopyTree, CopySelected and other Copy...action. These actions are usually accessible from CopyMenu menu.
It is possible to copy row only, copy row with children, copy row with children, but without values, copy selected rows – with or without children.
By API can be existing rows copies by CopyRows method.
Copying existing row by dragging
Existing rows can be copied when dragging by actions DragCopy, DragSelectedCopy, DragCopyChildren. These actions are not attached to any event by default, because by default are rows moved by dragging.
The copying actions can be attached to OnDrag... events and replace DragRow, DragSelected and DragChildren events that move the rows.
All the settings are described in Row moving documentation.
Moving existing row from another grid by dragging
From another grid are rows move always as copy – from source grid are deleted (marked as Deleted) and added as new to the destination grid.
The dragging rows can be done by actions DragRow, DragSelected and DragChildren events. These actions are usually attached as default actions for dragging rows to OnDrag event.
By API can be rows moved from another grid by MoveRowsToGrid method.
All the settings are described in Row moving documentation
Pasting row from clipboard
TreeGrid supports pasting new rows from clipboard. To clipboard can be rows copied from the grid, from another grid, or from another application like MS Excel.
The pasting is done by actions PasteTo... These actions are attached to CtrlV event and cannot be attached alsewhere.
All the settings are described in Copy&Paste documentation
By default every row accepts every child. Remember, only variable rows can be added or copied!
To control which row accepts which child use Def and AcceptDef attributes. The row accepts as child only rows with Def attribute listed in the row’s AcceptDef array. The root rows are controlled by <Root AcceptDef/>.
The new empty row gets its Def attribute from CDef attribute of its parent. Root rows use <Root CDef/>. To restrict adding to row’s children, set its CDef=””. By default is CDef=”R”.
Dynamically you can control adding new rows by API event OnCanRowAdd.
All the settings are described in Default rows documentation.
<Cfg> bool Adding [1] .
If rows can be added into grid.
If set to 0, grid does not permit adding new rows, copying existing rows and pasting rows from clipboard, but it is still permitted moving rows from another grid.
If set to 0, it hides Toolbar buttons Add and AddChild. If set to 0 all Add... actions fail, but AddRow method still works.
<Cfg> string AddFocusCol new 6.4 .
When set, automatically focuses this column after the row is added.
If not set, the originally focused column is used.
<I> bool Added [0] Uploaded to server, support Undo .
It is set to 1 when row has been added to the grid and not yet uploaded to server.
It is set to 1 for every type of adding the row (add empty, copy, drag copy, move from other grid, paste).
Added row is colored green (by default setting in Grid.css).
After uploading changes to server or calling AcceptChanges the added row just looses its state and becomes normal row.
The place where the row is added is identified by Parent, Next and Prev attributes.
<I> string Parent Uploaded to server .
When the row is moved or added, this is id of the new parent row or position of page (from 0).
<I> string Next Uploaded to server .
When the row is moved or added, this is id of the row below or “” if the row is the last row in its parent.
<I> string Prev Uploaded to server .
When the row is moved or added, this is id of the row above or “” if the row is the first row in its parent.
<I> <Root> int AddParent [0] .
If set, adds new row’s children as its siblings rather than its children.
If is set to 1 adds new row before the row.
If is set to 2 adds new row as last child of the parent row.
For example, if you set AddParent of all rows and <Root> to 2, every new row will be added to the end of table, to the root.
<Actions> AddRow ...F Attached to OnClickButtonAdd and OnIns and used in Toolbar Add and Panel CopyMenu .
Adds new empty row above actual or focused row.
<Actions> AddRowBelow ...F Not attached to any event .
Adds new empty row below actual or focused row.
<Actions> AddRowEnd Attached to OnClickButtonAdd event and used in Toolbar CopyMenu upd 6.0 .
Adds new empty row to the end of grid (when <Cfg AllPages=’1’/>) or actual page (when <Cfg AllPages=’0’/>).
There are also available actions AddRowEndGrid to add row to the grid end and AddRowEndPage to add row to actual page end.
<Actions> AddChild ...F Not attached to any event .
Adds new empty row into actual or focused row’s children to the beginning (as the first child)
<Actions> AddChildEnd ...F Attached to OnClickButtonAddChild and OnCtrlIns and used in Toolbar AddChild and Panel CopyMenu .
Adds new empty row into actual or focused row’s children to the end (as the last child)
API event bool OnCanRowAdd (TGrid grid, TRow parent, TRow next) .
Called before the row is added to find out if it can be added to this position.
It is called when adding new rows, copying existing rows and pasting rows. It is not called when moving rows from another grid.
parent is parent row in tree or page for root row, to its children the new row will be added.
next is next row, above it the new row will be added or null if the row will be added as the last child or last row on page.
API event void OnRowAdd (TGrid grid, TRow row) .
Called after the row is added, but before it is displayed. Usually to change default values.
API event void OnRowAdded (TGrid grid, TRow row) new 7.0 .
Called after the row is added and displayed.
Called also when the row is copied, but not moved from another grid by dragging (MoveRowsToGrid).
API method TRow AddRow (TRow parent, TRow next, bool show = false, string id = null, string Def = null) upd 6.4 .
Adds new empty row to grid and returns it. If show = true, the new row is also displayed, for false there must be called ShowRow method to display it.
parent is parent row, next is row below the new row. If next is null adds new row as the last parent’s child. If parent and next are null adds row as the last root row.
Also sets values to new row from its default row (according to CDef attribute of parent row).
If set id, sets it to id attribute, otherwise creates new unique id for the row.
If set Def, uses this Def as Default row name
Only variable row can be added.
<Cfg> bool Copying [1] .
If existing rows can be copied / duplicated.
If set to 0, the Panel Copy button is hidden and the CopyMenu does not display items for copying.
If set to 0, all Copy... actions fail but CopyRow and CopyRows methods still work.
Copying is automatically disabled when set Adding=’0’.
It is not related to Copy&Paste, it is controlled by Pasting.
<Cfg> bool CopyDeleted [0] new 6.4 .
If copies also deleted rows.
<I> bool CanCopy [1] upd 6.0 .
If the row can be duplicated and copied.
If set to 0, the Panel Copy button is inactive and all Copy... actions fail but CopyRow and CopyRows methods still work.
It is not related to copying values into clipboard.
<Header> bool CanCopy [0] .
If the Header Panel Copy button is enabled. Header row itself can never be never copied.
<I> string Copy Uploaded to server .
This attribute is set when used ChildPaging=3 and the row was created as deep copy of another row, the Copy is id of the source row
This attribute is set only if the source row has some children and they were not loaded from server yet (the row was not expanded yet).
The server script must provide deep copy of the children of source (Copy) node to children of this (id) node.
<Panel> bool Copy [0] upd 6.0 .
If the default Panel button Copy is visible. This button is hidden also if <Cfg Copying=”0”/>. This button is inactive when the row has CanCopy=’0’.
Click to this button shows popup menu for copying and adding rows. The menu is defined by attribute CopyMenu.
<Actions> CopyRow ...F Not attached to any event, but used in Toolbar Add and Panel CopyMenu .
Copies actual or focused row, the new row is placed above the source row
<Actions> CopyRowBelow ...F Not attached to any event new 6.0 .
Copies actual or focused row with all its children, the new row is placed below the source row
<Actions> CopyTree ...F Not attached to any event, but used in Toolbar Add and Panel CopyMenu .
Copies actual or focused row with all its children, the new row is placed above the source row
<Actions> CopyTreeBelow ...F Not attached to any event new 6.0 .
Copies actual or focused row with all its children, the new row is placed below the source row
<Actions> CopyEmpty ...F Not attached to any event, but used in Toolbar Add and Panel CopyMenu .
Copies actual or focused row with all children, but without their cell values, the new row is placed above the row.
<Actions> CopyEmptyBelow ...F Not attached to any event new 6.0 .
Copies actual or focused row with all children, but without their values, the new row is placed below the row.
<Actions> CopySelected ...F Not attached to any event, but used in Toolbar Add and Panel CopyMenu .
Copies selected rows the actual or focused row and place them before the actual or focused row.
It copies only rows that can be copied in the location. It fails if no selected row can be copied to the location.
<Actions> CopySelectedChild ...F Not attached to any event, but used in Toolbar AddChild and Panel CopyMenu .
Like CopySelected, but copies the rows as the first children of actual or focused row.
<Actions> CopySelectedChildEnd ...F Not attached to any event, but used in Toolbar AddChild and Panel CopyMenu .
Like CopySelected, but copies the rows as the last children of actual or focused row.
<Actions> CopySelectedTree ...F Not attached to any event, but used in Toolbar Add and Panel CopyMenu .
Like CopySelected, but copies the selected rows with all their children.
<Actions> CopySelectedTreeChild ...F Not attached to any event, but used in Toolbar AddChild and Panel CopyMenu .
Like CopySelectedTree, but copies the rows as the first children of actual or focused row.
<Actions> CopySelectedTreeChildEnd ...F Not attached to any event, but used in Toolbar AddChild and Panel CopyMenu .
Like CopySelectedTree, but copies the rows as the last children of actual or focused row.
<Actions> CopySelectedEmpty ...F Not attached to any event, but used in Toolbar Add and Panel CopyMenu .
Like CopySelected, but copies the selected rows with all their children, but without their cell values.
<Actions> CopySelectedEmptyChild ...F Not attached to any event, but used in Toolbar AddChild and Panel CopyMenu .
Like CopySelectedEmpty, but copies the rows as the first children of actual or focused row.
<Actions> CopySelectedEmptyChildEnd ...F Not attached to any event, but used in Toolbar AddChild and Panel CopyMenu .
Like CopySelectedEmpty, but copies the rows as the last children of actual or focused row.
<Actions> CopySelectedEnd Not attached to any event, but used in Toolbar Add and Panel CopyMenu upd 6.0 .
Like CopySelected, but copies the selected rows to end of grid (when <Cfg AllPages=’1’/>) or actual page (when <Cfg AllPages=’0’/>).
There are also available actions CopySelectedEndGrid to copy to the grid end and CopySelectedEndPage to copy to actual page end.
<Actions> CopySelectedTreeEnd Not attached to any event, but used in Toolbar Add and Panel CopyMenu upd 6.0 .
Like CopySelectedEnd, but copies the selected rows with all their children.
There are also available actions CopySelectedTreeEndGrid to copy to the grid end and CopySelectedTreeEndPage to copy to actual page end.
<Actions> CopySelectedEmptyEnd Not attached to any event, but used in Toolbar Add and Panel CopyMenu upd 6.0 .
Like CopySelectedEnd, but copies the selected rows with all their children, but without their cell values.
There are also available actions CopySelectedEmptyEndGrid to copy to the grid end and CopySelectedEmptyEndPage to copy to actual page end.
<Actions> CopyMenu ...F Attached to OnClickPanelCopy, OnClickButtonAdd and OnClickButtonAddChild upd 6.0 .
Shows popup menu for copying or adding rows. From this menu can be available all adding and copying actions listed above.
The menu items displayed are set by column or row attribute CopyMenu. The menu items captions are set in Text.xml.
<Panel><Space cell> string[] CopyMenu [...] new 6.0 .
What items (and their order) will be available in menu displayed by CopyMenu action – this actions attached to Panel Copy button and Toolbar Button Add and AddChild by default.
When the item action cannot be applied to the row, the menu item will be hidden even if it is set by this attribute.
It is comma separated array of these action names:
CopyRow, CopyTree, CopyEmpty, CopyRowBelow, CopyTreeBelow, CopyEmptyBelow,
CopySelected, CopySelectedTree, CopySelectedEmpty CopySelectedBelow, CopySelectedTreeBelow, CopySelectedEmptyBelow,
CopySelectedChild, CopySelectedTreeChild, CopySelectedEmptyChild, CopySelectedChildEnd, CopySelectedTreeChildEnd, CopySelectedEmptyChildEnd,
CopySelectedEnd, CopySelectedTreeEnd, CopySelectedEmptyEnd, CopySelectedEndGrid, CopySelectedTreeEndGrid, CopySelectedEmptyEndGrid,
CopySelectedEndPage, CopySelectedTreeEndPage, CopySelectedEmptyEndPage,
AddRow, AddRowBelow, AddRowEnd, AddRowEndGrid, AddRowEndPage, AddChild, AddChildEnd
By default is set in <Panel CopyMenu=’...’/> and <Toolbar AddCopyMenu=’...’ AddChildCopyMenu=’...’/>
API event void OnRowCopy (TGrid grid, TRow row, TRow source, bool empty) upd 6.4 .
Called after the row is copied, but before it is displayed. row is the copied row, source is the source row. empty is true if values were not copied.
Since 6.4 it is called also when pasting new row if set CopyPasteRows=1.
API event void OnRowCopyId (TGrid grid, TRow row, TRow source) new 6.4 .
Called before creating id for the new copied row, the row has already copied the IdNames columns, the other columns will be copied later.
API method void CopyRows (TRow[] rows, TRow parent, TRow next, bool deep = false, bool empty = false) chg 7.0 .
Copies all given rows inside grid. Shows all changes.
rows is array of the rows to copy in this order. The rows can be also from another grid.
parent is parent row, next is row below the copied rows. If next is null, places the rows as the last parent’s children. If parent and next are null, places rows as the last root rows.
If deep is true, copies include children, only visible (not filtered, not deleted).
Copies all row and cell attributes. Does not copy RowSpan.
In 7.0 was removed parameter dest_grid and rows now can become from another grid.
API method TRow CopyRow (TRow row, TRow parent, TRow next, bool deep = false, bool empty = false) chg 7.0 .
Copies one row inside grid. Returns the row copy.
row is the row to copy, it can be also from another grid,
parent is parent row, next is row below the copied row. If next is null, places the row as the last parent’s child. If parent and next are null, places row as the last root row.
If deep is true, copies include children, only visible (not filtered, not deleted).
Copies all row and cell attributes. Does not copy RowSpan.
Since 7.0 it also shows all the changes and tests if the copy is possible due Def / AcceptDef settings.