EJS TreeGrid documentation
Copy & paste via clipboard
TreeGrid supports copying cells, rows, columns and cell ranges into and from clipboard.
The data are in the same format as standard in spreadsheet programs like MS Excel, so it is possible to copy & paste cells between TreeGrid and MS Excel.
The format of copied & pasted data
Rows are separated by CRLF. Last row is not followed by CRLF. In pasting it accepts also single CR and LF as row separators.
Cells are separated by tabulator. Last cell is not followed by tabulator.
If cell value contains one of characters CR (\r), LF (\n) (
), tabulator (\t) (	) and double quote (“) ("), it encloses the value into double quotes and doubles all double quotes inside.
<C> bool CanCopyPaste [1] new 6.0.
If values can be copied from this column to clipboard by Ctrl+C and pasted to this column from clipboard by Ctrl+V.
If the column has CanCopyPaste = 0, it is ignored for both copying and pasting.
<I> int CanCopyPaste [1] new 6.0.
If values can be copied from this row to clipboard by Ctrl+C and pasted to this row from clipboard by Ctrl+V.
0 Row cannot be copied and pasted
1 Row can be copied and pasted
2 Row can be copied and pasted only with its parent (when set CopyTree).
3 Only for fixed row, the row is always copied when all rows are selected and copied or all variable rows are copied. By default it is set for main Header.
<Cfg> int CopyPasteTree [0] new 6.0.
If and how there will be copied children of the rows.
If set to another value than 0, it adds level information to beginning of the first cell, as count of characters U65279.
0 Does not copy tree
1 Copies also visible children of expanded parents
2 Copies also visible children of all parents
3 Copies also all children
<Cfg> int CopyPasteInternal [0] new 6.0.
0 Copies cell values to system clipboard and pastes from system clipboard.
1 Copies cell values to TreeGrid global private cache, it will be available for all grids on page.
2 Copies cell values to TreeGrid local private cache, it will be available only for this grid.
<Cfg> bool CopyPasteRows [0] new 6.3.
0 Copies cell values, but no other row or cell attributes.
1 Copies row ids only. It should be set with CopyPasteInternal>0 to copy the whole rows internally, with all attributes. Copies always all cells.
Copying to clipboard can be done only by pressing Ctrl + C or Ctrl + X.
There is no API method to copy to clipboard due browser security restriction.
<Cfg> bool CopySelected [1] new 6.0.
0 Never copy selected rows
1 Copy all selected rows/cells if any, otherwise copy focused row according to CopyFocused.
<Cfg> int CopyFocused [1] new 6.0.
It is applied only if CopySelected is 0 or if no row in grid is selected.
0 Never copy focused row
1 Copy only focused row
20 Copy all visible variable rows in the same parent as focused row
30 Copy all visible variable rows (if set CopyPasteTree, it affect only root rows, the other are handled by CopyPasteTree), copies also rows with CanCopyPaste=3.
31 Copy all variable rows (if set CopyPasteTree, it affect only root rows, the other are handled by CopyPasteTree) , copies also rows with CanCopyPaste=3.
<Cfg> bool CopyEdit [1] new 6.3.
0 Copies displayed text, usable for copying outside TreeGrid
1 Copies value in editable format, usable when copying inside grid
<Cfg> int CopyCols [1] new 6.0.
Which columns will be used for copy paste.
See also column attribute CanCopyPaste.
0 Only focused column
1 All visible columns
2 All columns
<cell> string CopyValue .
Cell value used for copying to clipboard by Ctr+C / Ctrl+X instead of actual cell value. Useful for HTML type columns.
<Cfg> int CopyTime [""] new 9.3.
Copying too many values to clipboard can be too slow and in this case the copying can fail, especially in IE and FF.
If the copying time exceeds this value (in milliseconds), the copying action is cancelled and the user must press the Ctrl+C again to finish the copying.
The CopyTime can contain up to four values used for different browsers in this order: [all, IE, FF, Safari/Chrome]
Reasonable value is "200,500,150,1000" or "150"
API event type OnGetCopyValue (TGrid grid, TRow row, string col, type val) .
Called to get value for copying to clipboard by Ctrl+C
val is predefined/actual cell value, return val or new value.
API event string OnGetRowText (TGrid grid, TRow row, string[] cols, string txt, bool sel) new 6.4.
Called to get the whole row text, without ending CRLF.
cols are the cells to copy, txt is the default text to copy, sel is set if only selected cells are wanted.
Return new row text to copy to clipboard or txt.
The row text must not contain CRLF string.
<Actions> Copy Attached to event OnCtrlC, can be attached only to OnCtrlC or OnCtrlX new 6.0.
Copies data to clipboard
Action in the CtrlC and CtrlX events must return 0 to permit the default function, use zero after comma like “Copy,0”
<Actions> Exclude Attached to event OnCtrlX, can be attached only to OnCtrlC or OnCtrlX new 6.0.
Copies data to clipboard and deletes the copied rows (only if all cells are copied)
Action in the CtrlC and CtrlX events must return 0 to permit the default function, use zero after comma like “Exclude,0”
API event bool OnCopyStart (TGrid grid) new 6.0.
Called before the data for copy is generated. Return true to suppress copying.
API event string OnCopy (TGrid grid, string txt) new 6.0.
Called after the data for copy is generated. txt is data to be copied to clipboard.
Return null to use the original txt, empty string to suppress copying or new text to copy.
Pasting from clipboard can be done only by pressing Ctrl + V.
There is no API method to paste from clipboard due browser security restriction.
<Cfg> bool Pasting [1] chg 6.0.
If pasting into grid is permitted
<Cfg> bool PasteSelected [1] new 6.0.
0 Never paste to selected rows
1 Paste to selected rows/cells if any, otherwise paste to focused row according to PasteFocused.
If the pasted range is bigger, the remaining source rows/cells are discarded
<Cfg> int PasteFocused [8] new 6.0.
It is applied only if PasteSelected is 0 or if no row in grid is selected.
0 Never paste to focused row
1 To focused row only, if the pasted range contains more rows, they are discarded.
2 To focused row and to the next rows below, in the same parent only, if the pasted range contains more rows, they are discarded.
3 To focused row and to the next rows below, including expanded children, if the pasted range contains more rows, they are discarded.
4 To focused row and new next rows are added after the focused row.
5 Inserts one new row in front of the focused row, if the pasted range contains more rows, they are discarded. The focused row itself is not changed.
6 Inserts new rows in front of the focused row. The focused row itself is not changed.
7 Inserts one new row in front of the focused row, if the pasted range contains more rows, they are discarded. The focused row itself is not changed.
If clipboard contains only one value, it pastes it to the actual focused cell.
8 Inserts new rows in front of the focused row. The focused row itself is not changed.
If clipboard contains only one value, it pastes it to the actual focused cell
20 Paste to all visible variable rows in the same parent as focused row
21 Replace all siblings of focused row by the pasted rows.
30 Copy all visible variable rows (if set CopyPasteTree, it affect only root rows, the other are handled by CopyPasteTree), copies also rows with CanCopyPaste=3.
31 Copy all variable rows (if set CopyPasteTree, it affect only root rows, the other are handled by CopyPasteTree) , copies also rows with CanCopyPaste=3.
32 Replace all variable rows with the pasted rows.
<Cfg> int PasteCols [4] new 6.0.
Which columns will be used for paste.
See also column attribute CanCopyPaste.
0 Paste only to focused column
1 Paste to all visible columns
2 Paste to all columns
3 Paste to all columns right to the focused cell, including the focused one
4 Paste from actually focused column or, if the data are longer than the rest right to the cursor, pastes from the first column (= 2 or 1 or 3)
<Cfg> int PasteTree [2] new 6.0.
0 Ignore the pasted children
1 Fill the children to the existing children only, use settings from CopyPasteTree.
2 Replace the children, if required, delete remaining children or add new children, use settings from CopyPasteTree.
<cell> int CanPaste [1] new 6.0.
If and how can be pasted values written to the cell.
If pasted value cannot be written to the cell, it is discarded (it is not written to the next cell)
0 The cell cannot accept pasted value
1 The cell accepts pasted value only if it is editable. To the pasted value are applied EditMask, ResultMask and Size.
2 The cell always accepts the pasted value as is.
API event bool OnPaste (TGrid grid, string[] cols, string[] pastedtext) chg 6.0.
Called before cell values are pasted by Ctrl+V from clipboard.
Return true to suppress default action.
pastedtext is array of texts to paste into individual rows. You can modify this array.
cols is array of column names only where will be pasting done. You can modify this array.
API event void OnPasteFinish (TGrid grid) chg 6.0.
Called after cell values was pasted from clipboard
API event bool OnPasteRow (TGrid grid, TRow row, string[] cols, string[] values, bool added) new 6.4.
Called before the values are pasted to the row cells (cols).
The cols array should not be modified – it is used also in next pasted rows.
added is set if the row was added by pasting.
Return true to cancel default behavior.
If true is returned and the row was added by pasting, it is not removed – must be removed by the handler!
API event void OnPasteRowFinish (TGrid grid, TRow row, string[] cols, string[] values, bool added) new 6.4.
Called after the values are pasted to the row cells (cols).
added is set if the row was added by pasting.
<Actions> Paste Attached to event OnCtrlV, can be attached only to OnCtrlV new 6.0.
Pastes data from clipboard
Action in the CtrlV event must return 0 to permit the default function, use zero after comma like “Paste,0”