Cell editing and changing values

TreeGrid documentation

Cell editability

upd 13.0 <Cfg> int

Editing

[1]
If and how values of grid can be edited. It does not affect rows of Kind = Filter, Group, Search.

0 - read only
Cells cannot be edited, cannot be switched to edit mode.
Bool and Radio types cannot be clicked. Enum type and Defaults list cannot be expanded.
The Date button is not displayed for Date type by default.

1 - editable
Cells can be edited. Default mode. The individual cell editability can be changed by their CanEdit attribute to 0 (read only) or 2 (preview).
Cells can be switched to edit mode and changed by user. Bool and Radio type can be changed by click.
Enum type and Default list can be expanded and value selected.
The Date button is displayed for Date type by default (can be hidden by setting the Button="").

2 - preview
Cells cannot be changed, but they can be displayed in read only edit mode.
The cell cannot be previewed if it has set CanEdit='0' (read only). The CanEdit='1' does not change to editable!
Bool and Radio types cannot be clicked. Enum type and Defaults list cannot be expanded.
The Date button is displayed for Date type by default, but the calendar dialog displayed on click is in read only mode.
The preview mode is intended especially for multiline types (Lines) to let user to display the whole text and also select it and copy to clipboard.

3 - read only not grayed
(new 13.0) The same as 0, but it is not grayed (similarly to ColorState without 4. bit set).
The default mode is 1 (editable), you can switch all editable cells to 0 - read only or 2 - preview mode by setting the Editing attribute.
<C><I><cell> int

CanEdit

[0/1]
If and how values in cells can be edited.
0 - read only, 1 - editable, 2 - preview. See Editing attribute.

The routine to find out the cell editability checks these points in this order:
1) If editing is suppressed (<Cfg Editing='0'/>) returns 0, except the Row Kind is Filter, Group, Search.
2) If the cell is not focusable (CanFocus='0') returns 0, except the cell Type is Bool or Radio.
3) Checks cell CanEdit, if it set, returns it.
4) Checks row CanEdit, if it set, returns it.
5) For Filter row returns 0 for Pass type and for columns with CanFilter='0' otherwise returns 1.
6) For calculated cell returns 0.
7) Checks column CanEdit, if it set, returns it.
8) Returns 0 or 1 according to the cell Type, default editable types are: Text, Lines, Int, Float, Date, Enum, Bool, Radio, Pass.
If point 3 - 8 returns 1 and set <Cfg Editing='2'/> returns 2.
After points 3 - 8 it calls OnCanEdit event to change the result dynamically.
API event int

OnCanEdit

(TGrid grid, TRow row, string col, int mode)
Called to check editability of the cell dynamically.
It is called in various situations, during rendering, before start edit, on mouse hover and so on.
This handler should be very fast and short.
The mode is preset editability, 0 - readonly, 1 - editable, 2 - preview.
Return new editability or the mode.
API method int

CanEdit

(TRow row, string col)
Checks if the cell can be edited, return 0 - read only, 1 - editable, 2 - preview.
new 12.0 <Actions>

SetEditable

,

SetEditableCells

,

SetEditableSelected ...F

Not attached to any event
Sets 1 to cell attribute CanEdit in actual or focused cell or in all focused cells or in all selected cells.
new 12.0 <Actions>

SetEditableRows

,

SetEditableSelectedRows ...F

Not attached to any event
Sets 1 to row attribute CanEdit in actual or focused row or in all selected rows.
new 12.0 <Actions>

SetEditableCols

,

SetEditableSelectedCols ...F

Not attached to any event
Sets 1 to column attribute CanEdit in actual or focused column or in all selected columns.
new 12.0 <Actions>

SetReadOnly

,

SetReadOnlyCells

,

SetReadOnlySelected ...F

Not attached to any event
Sets 0 to CanEdit in actual or focused cell or in all focused cells or in all selected cells.
new 12.0 <Actions>

SetReadOnlyRows

,

SetReadOnlySelectedRows ...F

Not attached to any event
Sets 0 to row attribute CanEdit in actual or focused row or in all selected rows.
new 12.0 <Actions>

SetReadOnlyCols

,

SetReadOnlySelectedCols ...F

Not attached to any event
Sets 0 to column attribute CanEdit in actual or focused column or in all selected columns.
new 12.0 <Actions>

SetPreview

,

SetPreviewCells

,

SetPreviewSelected ...F

Not attached to any event
Sets 2 to CanEdit in actual or focused cell or in all focused cells or in all selected cells.
new 12.0 <Actions>

SetPreviewRows

,

SetPreviewSelectedRows ...F

Not attached to any event
Sets 2 to row attribute CanEdit in actual or focused row or in all selected rows.
new 12.0 <Actions>

SetPreviewCols

,

SetPreviewSelectedCols ...F

Not attached to any event
Sets 2 to column attribute CanEdit in actual or focused column or in all selected columns.
new 12.0 <Actions>

ClearEditable

,

ClearEditableCells

,

ClearEditableSelected ...F

Not attached to any event
Sets null to CanEdit in actual or focused cell or in all focused cells or in all selected cells.
new 12.0 <Actions>

ClearEditableRows

,

ClearEditableSelectedRows ...F

Not attached to any event
Sets null to row attribute CanEdit in actual or focused row or in all selected rows.
new 12.0 <Actions>

ClearEditableCols

,

ClearEditableSelectedCols ...F

Not attached to any event
Sets null to column attribute CanEdit in actual or focused column or in all selected columns.

Defaults list

A list of predefined values for the cell to let a user to choose one or more of them.
Displayed on click to button or by API.
This list can be used also for non editable cells of any Type, it does not depend on CanEdit settings.
Since 9.2 it is possible to simulate Enum value/key pairs by Html type and its Format attribute.
chg 6.0 <C> <cell> string

Button

["Defaults"]
To show right side button with Defaults list set Button="Defaults".
It can be shown also by Icon="Defaults".
chg 6.0 upd 9.2 <C> <cell> string[*]

Defaults

A first character separated list of values to select to the cell. A user can choose one value from combo or even more values if Range is set.
Or it can be in standard TreeGrid menu format as complex menu with sub levels, sub menus, columns and so on.
It is used when set Button="Defaults" or Icon = "Defaults" or Type="Select". It can be used for cell of any Type.
To show a list of predefined values while editing use Suggest list instead.
Separator can be shown as item named '-'.

Since 9.2 the Defaults can be used with name/key pairs using new Format and EditFormat attributes structure for Text, Lines and Html types.
For example <C Name="A" Button="Defaults" Defaults="|one|two|three" Format="{1:'one',2:'two',3:'three'}" EditFormat="{1:'one',2:'two',3:'three'}"/> will show/edit strings one, two, three, but cell values will be 1,2,3.

The list can contain special items starting with '*':
*DateAfter click on menu item it shows calendar to select date.
*ButtonAfter click on menu item it calls OnButtonClick user event for the cell.
*DefaultItem contains default value for the cell (value from Def row).
*FilterOffSwitches off the filter operator, only for filter row.
*AllChooses all items for range.
*NoneSelects empty range.
*Rows...There will added more items containing values from other rows in this column according other settings:
...Variable...from variable rows (used also if no Fixed / All / Sibling is present)
...Fixed...from fixed rows
...All...from fixed and variable rows
...Sibling...from sibling rows
...Def...only from rows that have the same default (Def attribute) as the row
...DefXXX*...(since 7.0) only from rows that have its default (Def attribute) named XXX
...Visible...only visible rows
...CanFilter...(for Filter row) only rows that can be filtered according to this column
...n...maximally n most frequent values
...ColXXX*...values from another column, XXX is column name, from left must have prefix 'Col' and from right postfix '*'.
...Alphabet...(new 6.1) the menu items will be divided to submenus according to the first letter. Useful for long menus. See also DefaultsAlphabetWhite.
The menu item name is defined by <Lang><Text DefaultsAlphabet='%d ...'/>, the %d will be replaced by the character.
For example: "*RowsDef20" returns maximally 20 variable rows with the same default row.
<C> <cell> bool

DefaultsServer

[0]
If set to 1, TreeGrid dynamically downloads the Defaults list from server side by <treegrid> Cell_Url settings before it displays it (after the button was clicked).

Example:Let's have row MyRow with cell MyCol with Defaults button:
<I id='MyRow' MyColButton='Defaults' MyColDefaultsServer='1' ...
Set in your TreeGrid definition:
<treegrid Cell_Url='myscript.jsp' Cell_Data='MyData' ...
And the myscript.jsp (or .aspx, .php) will get such XML in MyData property:
<Grid> ... <Body> <B id='MyRow' Col='MyCol'/> </Body> </Grid>
And the myscript should return XML to update the Defaults list in the appropriate row cell:
<Grid> <Changes> <I id='MyRow' MyColDefaults='the prepared list'/> </Changes> </Grid>
new 6.1 <Cfg> string

DefaultsAlphabetWhite

["!"#$%&'()*+,-./:;<=>?@[\]^_{|}"]
Characters ignored when grouping items by *Alphabet keyword in Defaults.
new 7.0 <C> <cell> int

DefaultsAlphabetMin

[0]
Minimal count of the items starting by the same character to group them, by *Alphabet keyword in Defaults.
For example if set to 2, there will not be created sub menus with one item only.
API event string

OnGetDefaults

(TGrid grid, TRow row, string col, string defaults)
Called before displaying menu Defaults to get the list dynamically.
Returns original or modified defaults list.
Or return null to not show the list.
new 6.3 API event void

OnShowDefaults

(TGrid grid, TRow row, string col, TMenu Menu, TPosition Pos)
Called before displaying menu Defaults to update the menu dynamically.
It can be used to do any modification in Menu, for example to sort or change position in Menu.Items array. See Menu documentation.
<Actions>

ShowDefaults ...F

Displays dialog Defaults for the actual or focused cell.
new 12.0 <Actions>

ShowDefaultsMenu ...F

Displays dialog Defaults for the actual or focused cell.
Displays it even if the cell has no Button/Icon = "Defaults".
new 10.0 API method bool

ShowDefaults

(TRow row, string col)
Displays dialog Defaults for given cell.
new 12.0 API method bool

InDefaults

(TGrid grid, TRow row, string col, string val = null, string defaults = null)
Checks if the cell value or val is in its defaults list or in defaults.
Returns true if the list contains the value, false if the list does not contain the value and null if the defaults list is empty or not set.
Works for all formats of Defaults list. Can be used also to check Suggest list, if placed as defaults parameter.
new 6.0 API method int

GetDefaultsIndex

(TGrid grid, TRow row, string col, string val = null)
Returns index (from 0) of actual cell value inside its Defaults array.
Returns null if the value is not in the Defaults array or the Defaults array does not exits.
If set val, compares this value instead of the cell one.
Works only for simple defaults as first character separated array, without special items (*) and not as TreeGrid Menu.
new 6.0 API method string

GetDefaultsValue

(TGrid grid, TRow row, string col, int index)
Returns an item from Defaults array in the given position index (from 0).
Returns null if the index is outside defaults boundary or the Defaults array does not exits.
Works only for simple defaults as first character separated array, without special items (*) and not as TreeGrid Menu.

Suggest list (auto complete)

A list of predefined values for the cell and actual input to let a user to choose one of them.
Displayed while editing and updated whenever the input text changes.
new 6.0 upd 9.2 <C> <cell> string[*]

Suggest

A list o values to suggest them to user while editing.
It contains all items that can be suggested for the cell.
The user will see only items that contain already entered part of the value in input. The searching is case insensitive.
The Suggest can contain also the special items starting by * like Defaults menu.

Since 9.2 the Suggest can be used with name/key pairs using new Format and EditFormat attributes structure for Text and Lines types.
For example <C Name="A" Suggest="|one|two|three" Format="{1:'one',2:'two',3:'three'}" EditFormat="{1:'one',2:'two',3:'three'}"/> will show/edit strings one, two, three, but cell values will be 1,2,3.
If used SuggestType='Existing,...', the above example should define Suggest="{Items:[{Name:1,Text:'one'},{Name:2,Text:'two'},{Name:3,Text:'three'}]}"
Due internal implementation no key can be equal to value, e.g. {a:'b',b:'c'}, the b cannot be both key and value.
new 6.0 upd 12.0 <C> <cell> string[]

SuggestType

Various settings for Suggest menu. Comma separated list of keywords, case insensitive:
Replaceif set, replaces the actual edit input while changing selected item in the suggest menu by cursor keys
Startif set, shows the suggest menu also on start editing for current value
StartAll(new 11.0) if set, shows the full suggest menu also on start editing
Emptyif set, shows the full suggest menu also for empty input value
Allif set, shows the full suggest menu always - it does not search the current input value
Case(new 6.2) if set, preserves case sensitivity, shows only items that contains the text in the same case
WhiteChars(new 10.0) uses WhiteChars cell attribute value for comparing
CharCodes(new 10.0) uses CharCodes cell attribute value for comparing
Complete(new 6.2) auto completes the input value if there is only one value to suggest
Existing(new 6.2) accepts only values existing in the actual suggest menu
Begin(new 6.2) the suggested items must start with the value (otherwise the item is suggested if any its word starts with the value)
Search(new 12.0) the suggested items are searched in any place, not only in the word start (cannot be used with Begin)
Separator (new 6.4) after selecting suggested item for the last value, adds also SuggestSeparator to the end. Used only if set SuggestSeparator.
(since 12.1) If SuggestSeparator contains Regex expression, it adds the first character from this Regex, so for this case the Regex should look like ";|[;,\s]" to add the ";".
BeforeSeparator(new 12.0) after selecting suggested item it places cursor before the next separator, if any. Used only if set SuggestSeparator.
Esc(new 6.5) escape hides the suggestion menu instead of cancelling editing
Arrows(new 6.5) in multiline edit the up/down arrows will be used in suggest menu. If not set, Ctrl + arrows control the suggest menu
new 6.2 <C> <cell> int

SuggestDelay

Delay before the suggest menu is shown. If next key is pressed within this time, the menu is not shown for the previous text.
new 6.2 <C> <cell> int

SuggestMin

Minimal count of characters in text to show the suggest menu for the text.
new 6.4 upd 12.0 <C> <cell> string

SuggestSeparator

Set for range values separated by this separator.
If set, suggest is shown separately for the individual parts of the value. After choose suggest item, it replaces the part by the item and does not end editing.
To add the separator also to the end after item is selected like in MS Outlook, set SuggestType, value Separator.
Default value is empty for normal cells, and ValueSeparator (semicolon by default) for Range cells.
It can be set also to "&#x0a;" for enter as separator in multiline cells.
Since 12.0 it can be set to one character or to Regex expression for more separators (e.g. "[,\.;]" to separate by any of the ",.;".
new 12.0 <C> <cell> string[*]

FormulaSuggest

A list o values to suggest for editable formula, when the edited value starts by '='. Format is the same as Suggest.
Or it can be set to number to generate the suggest list for all available functions.
1 - generates and shows only function names, 2 - generates function name plus open brace, 4 - shows function names with braces, 6 = 2+4.
new 12.0 <C> <cell> string[]

FormulaSuggestType

["BeforeSeparator"]
Various settings for FormulaSuggest menu for editable formula. Format is the same as SuggestType.
new 12.0 <C> <cell> int

FormulaSuggestDelay

Delay before the suggest formula menu is shown. If next key is pressed within this time, the menu is not shown for the previous text.
new 12.0 <C> <cell> int

FormulaSuggestMin

Minimal count of characters in text to show the suggest formula menu for the text.
new 12.0 <C> <cell> string

FormulaSuggestSeparator

"[+\-*\/!%&|^<>=?:()\[\]{}"',~]+"
Sets regex for all characters that separate the formula function names. Has the same format as SuggestSeparator
By default it is set to all operator characters.
new 6.0 upd 12.0 API event string

OnSuggest

(TGrid grid, TRow row, string col, string val, TMenu suggest, bool formula)
It is called whenever the value is changed by user while editing to get the appropriate defaults for the value.
The val is actual value, the suggest is the proposed suggest menu.
The formula (new 12.0) is true if called for FormulaSuggest.
Return new suggest string or the suggest. The returned suggest is not searched for the val again and is displayed always the whole.
The OnSuggest is not called when set SuggestServer='1'.
new 6.0 <C> <cell> bool

SuggestServer

For dynamic loading the suggest menu list from server. It is not used for editable formula (FormulaSuggest).
If set to 1, TreeGrid downloads the Suggest attribute setting from server side <treegrid> Cell_Url settings whenever a user changes the input value while editing.
The returned suggest is not searched for the val again and is displayed always the whole.
For example you can return for cell [row id='R1' col='Col1'] such XML to change the Suggest menu:
<Grid><Changes><I id='R1' Col1Suggest='|One|Two|Three'/></Changes>clt;/Grid>
If you change from server also Format / EditFormat, you should set <Changed Update='32'> to not refresh the edited cell.
new 6.2 upd 12.0 API event string

OnGetSuggest

(TGrid grid, TRow row, string col, string suggest, bool formula)
Called to get the complete Suggest attribute once on start editing.
The formula (new 12.0) is true if called for FormulaSuggest.

Changing cell value

<I> bool

Changed

[0] Uploaded to server, supports Undo
It is set to 1 when any cell value in the row has been changed. Which cell is specified by the cell's attribute Changed.
If the changed cell value is set back to its original value, the cell and row looses the Changed flag, except is set <Cfg StoreOriginalValues='0'.
After uploading changes to server or calling AcceptChanges the changed row just looses its state and becomes normal row.
<cell> bool

Changed

[0] Uploaded to server, supports Undo
It is set to 1 when the cell value has been changed.
new 11.0 <C><cell> bool

NoChanged

[0]
If set to 1, the cell is never marked as Changed and the row Changed is never set due changes in this cell.
upd 12.0 API event type

OnValueChanged

(TGrid grid, TRow row, string col, type val, type oldval, object errors)
Called before cell value is changed by a user input. It is called even if a user entered the same value.
This event is called when a user edited cell, selected item from Defaults or Enum list, selected date from calendar, clicked and changed Bool or Radio cell, dragged column to DropCols cells.
Since 12.0 it is called also when more cells are changed by clearing cell range, moving or copying cell range, filling cell range or pasting to cells.
Use this event to change or update the entered value. To do some action after finish edit call OnEndEdit instead.
Return new value or the entered value val.
Since 12.0 oldval is actual value in cell or its formula. Return it to not change the cell value at all.
Since 12.0 The errors is set when called during some mass change, e.g. pasting, see OnEditErrors API event.
upd 6.0 API event void

OnAfterValueChanged

(TGrid grid, TRow row, string col, type val)
Called after cell value is changed by user edit, only if the value was changed to another.
Called before the changed value is shown in the cell.
Use this event to run code after cell value is modified.
new 6.0 <C> <cell> bool

CaseSensitiveValues

[1]
If strings are stored case sensitive.
If set to 0, the input value is always converted to lower case.
<Cfg> bool

StoreOriginalValues

[1]
If all the cell values are stored before they are changed. If the values are stored and the cell value is set back to the original value, the row is marked back as not Changed.
Set it to 0 just to save memory, if you don't need this behavior.
<Cfg> bool

SaveValues

[0]
If set to 1, saves all changed cell values of all rows to cookies.
It can be used only for very small grids their changes are not uploaded to server. Usually for grids that controls something on client side.
Remember, cookies are limited to 4096 bytes for the whole page, so use this setting only for very small static tables or use PersistentCfg.
Use the smallest row ids and column names as possible (the amount of space is used: (name+1)+id+value+2 bytes per row).
Also use it only for number tables or restrict input strings length by edit mask.
API method void

SetValue

(TRow row, string col, type val, bool refresh = 0)
Sets the cell value.
The val should be already type of the cell, the Date type must be set as count of milliseconds and Int and Float type should be set as JavaScript Number.
Set refresh to true to display changes in grid or call RefreshCell method.
This method updates all things around the setting value like calculations, master / detail, CopyTo, id, AutoUpdate and so on.
It does not call OnValueChanged / OnAfterValueChanged events.
For synchronized Gantt cells (like Start/End/Duration or Descendants/Ancestors) call CheckGantt before SetValue to update also the other Gantt cells.
API method void

SetString

(TRow row, string col, type val, bool refresh = 0)
Sets cell values as string in data xml format, the format affects especially Date type.
Set refresh to true to display changes in grid or call RefreshCell method.
This method converts the string to value and calls SetValue.
<XML event> void

OnChange

(TGrid Grid,TRow Row, string Col, TEvent Event)
Called as <Actions> or cell event when cell value is changed.
Attach the action or any JavaScript code to the cell to be run on cell value change, like <I ... Col1OnChange='alert("changed!")' ... />
The new value can be got by Get(Row,Col).
It is called from SetValue.
new 10.0 <XML event> void

OnSame

(TGrid Grid,TRow Row, string Col, TEvent Event)
Called as <Actions> or cell event when cell value is edited and accepted, but not changed.
Attach the action or any JavaScript code to the cell to be run on cell value change, like <I ... Col1OnChange='alert("changed!")' ... />
The value can be got by Get(Row,Col).
It is not called from SetValue, it is called only when the value was edited or selected by a user.

Mass cell change

Changing values and attributes of more editable cells at once.

NameActionAPIDescription
Actions affected by EditAttrs and EditErrors and calling OnEditAttrs, OnValueChanged, OnAfterValueChanged and OnEditErrors
"Clear"ClearCell + 23 moreClearRangeClear cell or cell range. Usually by pressing del key
"Copy"CopyFocus + 2 moreCopyRangeCopy focused cell range. Usually by mouse dragging
"Move"MoveFocus + 2 moreCopyRangeMove focused cell range. Usually by mouse dragging ("Copy"+"Clear")
"Fill"FocusFillRowCol +6 moreFillRangeAuto fill focused or dragged cell range. Usually by mouse dragging
"Paste"PastePaste cell focused or selected range from clipboard
Actions affected by EditAttrs only
"CopyRow" CopyRow + 7 more
CopyTree + 7 more
CopyRow
CopyRows
Copying the whole row(s)
By default, if no EditAttrs are set, copies all row and cell attributes.
If EditAttrs is set, copies only these cell attributes, no other row and cell attributes.
"CopyCol" CopyCol + 5 more
ColCopy + 1 more
AddCol
AddCols
Copying the whole column(s)
By default, if no EditAttrs are set, copies values and editable formulas and all column attributes.
If EditAttrs is set, copies these cell attributes and also all column attributes.
Actions affected by EditAttrsEmpty only
"AddRow" AddRow + 7 more
CopyEmpty + 7 more
AddRow
AddRows
Adding new row(s) above or below focused row(s).
By default, if no EditAttrsEmpty are set, adds the row empty with only default attributes.
If EditAttrsEmpty is set, copies also these cell attributes from the originally focused row(s).
"AddCol" AddCol + 6 more AddCol
AddCols
Copying the whole column(s)
By default, if no EditAttrs are set, copies values and editable formulas and all column attributes.
If EditAttrs is set, copies these cell attributes and also all column attributes.
Actions affected by EditErrors and calling OnEditErrors
"Formula"Calculate editable formulas in all cells
"Validate"Validate Validating all cell values against cell restrictions
(only if Cfg Validate contains flag Messages)

Adding to end, moving, deleting, resizing, filtering, grouping and searching the whole row(s) and column(s) are not taken as mass change and do not use EditAttrs and EditErrors.
new 12.0 <Cfg> string[]

EditAttrs

[...]
Comma separated list of cell attribute names that will be changed by mass edit action.
This list must contain item "Value" to change the cell value, otherwise the cell value is not changed.
To affect editable formulas include item "EFormula".
Include any cell attribute like Type or Format to be set. It is not possible to set any Gantt attributes.
Default value is "Value,EFormula,Span,RowSpan" for all actions except row copy. For row copy are copied all attributes by default.
The EditAttrs can be set directly before every mass action call to have different behavior for every mass action, e.g. <Actions OnDel="Grid.EditAttrs='Value',ClearValues" OnCtrlDel="Grid.EditAttrs='Value,EFormula',ClearValues'"/>
new 12.0 <Cfg> string[]

EditAttrsValue

[...]
EditAttrs used for changing value only.
By default it contains "Value,EFormula" if listed in EditAttrs.
new 12.0 <Cfg> string[]

EditAttrsStyle

[...]
EditAttrs used for changing all cell attributes except value.
By default it contains all attributes listed in EditAttrs except Value and EFormula.
new 12.0 <Cfg> string[]

EditAttrsEmpty

[ ]
EditAttrs used for added empty rows and columns.
By default the rows and columns are added empty. If set the EditAttrsEmpty, it copies these attributes from source focused rows or columns like the rows or columns are being copied.
It affects adding rows below or above the actual or focused row, copying empty row tree structure and adding columns left or right to actual or focused column.
It does not affect adding row and column to the grid end.
new 12.0 API event type

OnEditAttrs

(TGrid grid, TRow row, string col, type value, type oldvalue, type[] attrvalues, string[] attrnames, object errors)
Called when the cell value and / or its attributes is changed by some mass edit action, see them in the Mass cell change.
value is value to be set to the cell (including EFormula), oldvalue is actual value in the cell (including EFormula).
value is null when clearing the cell.
Return new value to be set to the cell or the value or the oldvalue to not change the value.
attrvalues are values that will be set to cell attributes their names are in attrnames. It is possible to modify both the values in attrvalues and in attrnames.
For errors see OnEditErrors API event.
new 12.0 <Cfg> int

EditErrors

[2]
If the mass changes are checked against cell restrictions and errors messages are shown for every the mass change error.
0 - no check & error, 1 check restrictions, but don't show error message, 2 check & show message.
new 12.0 API event type

OnEditErrors

(TGrid grid, object errors)
Called after mass cell change in grid is done, to process the errors.
The errors object has set these properties:
Actionas the mass edit action:
"Clear" for clear cell values (action ClearValues)
"Move" for move cell range (action MoveFocus)
"Copy" for copy cell range (action CopyFocus)
"Fill" for auto filling cell values
"Paste" for pasting values from clipboard
"Formula" for editable formula calculation
"Validate" for action Validate (only if Cfg Validate contains flag Messages)
Errors as JavaScript array of arrays as [[message1,row1,col1],[message2,row2,col2],...] of cells where the value was not set due cell restriction.
Changes as JavaScript array of arrays as [[message1,row1,col1],[message2,row2,col2],...] of cells where the value was modified due cell restriction.

The errors object can be also modified by API events OnValueChanged, OnEditAttrs, OnMoveFocusValue, OnAutoFillValue, OnPasteValue, OnResultMask, OnValidate and OnFormula.

The function can provide its own action to handle the errors and return true.
Or it can modify the error properties and return false to process them by TreeGrid.
new 12.0 <Cfg> int

EditErrorsMessageMax

[10]
Maximal count of edit error messages to display in the grid message dialog.
new 12.0 <Cfg> int

EditErrorsMessageTime

[1000]
How long, in milliseconds, the Message in errors object (see in OnEditErrors) will be displayed. 0 means forever.
new 12.0 API event bool

OnEmptyRow

(TGrid grid, TRow row)
Called to find out if the row is empty, if it does not contain any the EditAttrs attribute value.
Return true if the row is empty, false if it is not empty.
Called to find the last row for save, export, print in AutoPages and the last row to remove for RemoveAutoPages.
new 12.0 API event bool

OnEmptyCol

(TGrid grid, string col)
Called to find out if the column is empty, if it does not contain any the EditAttrs attribute value.
Return true if the column is empty, false if it is not empty.
Called to find the last column for save, export, print in AutoColPages and the last column to remove for RemoveAutoColPages.
new 12.0 API method TRow

GetLastDataRow

( )
Returns last not empty root row in the grid according to the EditAttrs.
new 12.0 API method string

GetLastDataCol

( )
Returns last not empty column in the grid according to the EditAttrs.

Clearing cells

new 12.0 <Actions>

ClearCell ...F

Not attached to any event
Clears value and all other EditAttrs attributes in the focused or actual cell.
Sets the cell value to default value or to 0 in Int, Float and Date types (if CanEmpty is not set) or to empty string.
Sets all the attribute values to null, so the default values are used. Only RowSpan and Span sets to 1.
new 12.0 <Actions>

ClearValue ...F

Not attached to any event
Clears value and EFormula in the focused or actual cell. Or clears the attributes listed in EditAttrsValue.
Sets the cell value to default value or to 0 in Int, Float and Date types (if CanEmpty is not set) or to empty string.
new 12.0 <Actions>

ClearStyle ...F

Not attached to any event
Clears all attributes except value and EFormula in the focused or actual cell. Or clears the attributes listed in EditAttrsStyle
Sets all the attribute values to null, so the default values are used. Only RowSpan and Span sets to 1.
new 12.0 <Actions>

ClearCells ...F

Not attached to any event
Clears all focused cells like ClearCell. Version without ...F fails if the actual cell is not focused.
new 12.0 <Actions>

ClearValues ...F

Not attached to any event
Clears values in all focused cells like ClearValue. Version without ...F fails if the actual cell is not focused.
new 12.0 <Actions>

ClearStyles ...F

Not attached to any event
Clears attributes in all focused cells like ClearStyle. Version without ...F fails if the actual cell is not focused.
new 12.0 <Actions>

ClearSelectedCells ...F

Not attached to any event
Clears all selected cells like ClearCell. Version without ...F fails if the actual cell is not selected.
new 12.0 <Actions>

ClearSelectedValues ...F

Not attached to any event
Clears values in all selected cells like ClearValue. Version without ...F fails if the actual cell is not selected.
new 12.0 <Actions>

ClearSelectedStyles ...F

Not attached to any event
Clears attributes in all selected cells like ClearStyle. Version without ...F fails if the actual cell is not selected.
new 12.0 <Actions>

ClearRow ...F

Not attached to any event
Clears all cells in actual or focused row like ClearCell.
new 12.0 <Actions>

ClearRowValues ...F

Not attached to any event
Clears values in all cells in actual or focused row like ClearValue.
new 12.0 <Actions>

ClearRowStyles ...F

Not attached to any event
Clears attributes in all cells in actual or focused row like ClearStyle.
new 12.0 <Actions>

ClearSelectedRows ...F

Not attached to any event
Clears all cells in all selected rows like ClearCell. Version without ...F fails if the actual row is not selected.
new 12.0 <Actions>

ClearSelectedRowsValues ...F

Not attached to any event
Clears values in all cells in all selected rows like ClearValue. Version without ...F fails if the actual row is not selected.
new 12.0 <Actions>

ClearSelectedRowsStyles ...F

Not attached to any event
Clears attributes in all cells in all selected rows like ClearStyle. Version without ...F fails if the actual row is not selected.
new 12.0 <Actions>

ClearCol ...F

Not attached to any event
Clears all cells in actual or focused column like ClearCell.
new 12.0 <Actions>

ClearColValues ...F

Not attached to any event
Clears values in all cells in actual or focused column like ClearValue.
new 12.0 <Actions>

ClearColStyles ...F

Not attached to any event
Clears attributes in all cells in actual or focused column like ClearStyle.
new 12.0 <Actions>

ClearSelectedCols ...F

Not attached to any event
Clears all cells in all selected columns like ClearCell. Version without ...F fails if the actual column is not selected.
new 12.0 <Actions>

ClearSelectedColsValues ...F

Not attached to any event
Clears values in all cells in all selected columns like ClearValue. Version without ...F fails if the actual column is not selected.
new 12.0 <Actions>

ClearSelectedColStyles ...F

Not attached to any event
Clears attributes in all cells in all selected columns like ClearStyle. Version without ...F fails if the actual column is not selected.
new 12.0 <Actions>

ClearAll

Not attached to any event
Clears all cells in grid like ClearCell.
new 12.0 <Actions>

ClearAllValues

Not attached to any event
Clears values in all cells in grid like ClearValue.
new 12.0 <Actions>

ClearAllStyles

Not attached to any event
Clears attributes in all cells in grid like ClearStyle.
new 12.0 API method void

ClearRange

(type[] range)
Clears value and all other EditAttrs attributes in all cells in the given range as [TRow row1, string col1, TRow row2, string col2].
Sets the cell values to default value or to 0 in Int, Float and Date types (if CanEmpty is not set) or to empty string.
Sets all the attribute values to null, so the default values are used. Only RowSpan and Span sets to 1.

Editing cells

chg 6.0 <Cfg> int

InEditMode

[2]
If the edit mode is started on click, on double click or on character key press.
It presets actions OnDblClickCell, OnKey and OnBackspace. You can modify these actions by yourself to get more options.
It is tested also in FocusEdit action attached to OnClickCell by default.
The default actions settings corresponds to InEditMode='2', but without modifications of the event actions.
0the edit mode is run only when user clicks to already focused editable cell or double clicks some editable cell or presses Enter or F2.
1the edit mode is run when user clicks to any cell or presses character key or Enter, F2 or Backspace.
2the edit mode is run when user clicks to already focused editable cell or double clicks some editable cell or presses character key or Enter, F2 or Backspace.
new 6.0 chg 12.0 <Cfg> int

EnterMode

[0]
The Enter key behavior, if and how it moves edit cursor.
It presets actions OnEnter and OnEnterEdit. You can modify these actions by yourself to get more options.
0Standard mode, Enter accepts value and do nothing else, no modification to OnEnter and OnEnterEdit.
1Enter starts editing cell below, it sets <Action OnEnterEdit='AcceptEdit AND TabDownEdit,1' OnEnter='TabDownEdit'/> (chg 12.0)
2Enter starts editing cell below and on the last row adds new row and moves to it, it sets <Action OnEnterEdit='AcceptEdit AND GoDownEditAdd,1' OnEnter='GoDownEditAdd'/>
3Enter starts editing cell right, it sets <Actions OnEnterEdit='AcceptEdit AND TabRightEdit,1' OnEnter='TabRightEdit'/>
4Enter starts editing cell right and on the last row and cell adds new row and move to it, it sets <Actions OnEnterEdit='AcceptEdit AND TabRightEditAdd,1' OnEnter='TabRightEditAdd'/>

To support also other cell types than the <input> ones, e.g. Enum type, don't define the EnterMode, but implement it by API event OnEndEdit like:
Grids.OnEndEdit = function(G,row,col,save,val){ if(save) setTimeout(function(){ if(row!=G.FRow||col!=G.FCol) return; G.ActionTabRightEdit(); if(G.GetType(G.FRow,G.FCol)=="Enum") G.StartEdit(); },10); }
upd 11.0 <Cfg><C><cell> int

AcceptEnters

[0]
How the Enter key will be handled in Lines type and optionally in other type cells. Bit array.
For 0 the Enter key accepts changes and finishes editing.
For 1 the Enter key inputs LF character (&#x0A). To finish editing is possible by Ctrl / Alt / Shift + Enter or Tab or click outside the cell.
For 2 (new 11.0) the Ctrl / Alt / Shift + Enter key inputs LF character (&#x0A). To finish editing is possible by Enter or Tab or click outside the cell.
For 3 (new 11.0) the Enter and Ctrl / Alt / Shift + Enter key inputs LF character (&#x0A). To finish editing is possible by Tab or click outside the cell.
For 4, 5, 6, 7 (new 11.0) is the same as 0, 1, 2, 3, but it is used also for other types than Lines. If the entered value contains LF, the cell Type is set to Lines.
new 11.0 upd 13.0 <Cfg> int

EditSelect

[7]
If the cell value will be selected on start editing. Bit array.
0 - no; 1 - on mouse action; 2 - on key action; 3 - always. + 4 (new 13.0) also if edited tab button (usually sheet name).
If the value is not selected, the input caret is placed on mouse position or in the value end.
new 11.0 <Cfg> int

EditHtml

[0]
If and how the Html Type cell will be edited.
0 - As Html and only if the cell has explicitly set CanEdit='1'.
1 - As Html always except if the CanEdit attribute is set to '0'.
2 - As Text always except if the CanEdit attribute is set to '0'.
3 - Like 2, but it asks before saving the value if the original value contained some Html code.
new 6.7 <C> <cell> bool

CancelUnchanged

[0]
If set to 1, it does not save the value, if the entered string was not changed by a user.
It is intended to be used when the value is changed just by entering end leaving edit mode in the cell due EditFormat or DefaultDate settings.
API variable bool

EditMode

read only
If focused cell is being edited now.
It is set if the <input> or <textarea> is shown in grid or the Enum list is expanded.
It is set also if grid is in preview mode (the <input> or <textarea> is shown as read only).
upd 6.0 <C> <cell> bool

EditServer

For dynamic loading cell settings and content for editing the value.
If set to 1, TreeGrid downloads the cell settings from server side by <treegrid> Cell_Url settings before it starts cell editing.
After the edit finishes, all the cell settings (but only this cell settings) are restored to original values before the new value is accepted or rejected.
The server response should contain the <Changes> with attributes to change, only the actual cell settings should be changed.
For example you can return for cell [row id='R1' col='Col1'] such XML to change the type for editing:
<Grid><Changes><I id='R1' Col1Type='Enum' Col1Enum='|One|Two|Three'/></Changes></Grid>
It will change cell type to Enum and download Enum list from server side and let a user to select the value from it.
API event bool

OnStartEdit

(TGrid grid, TRow row, string col)
Called before started editing of textual cell (in <input> or <textarea>) or before Enum list is expanded.
Return true to suppress editing.
chg 6.0 upd 10.0 API event type

OnEndEdit

(TGrid grid, TRow row, string col, bool save, type val, string raw)
Called before editing is finished in textual cell (in <input> or <textarea>) or before Enum list is closed. It is not called after change in Bool, Radio or Select type.
The save is 1 if a user accepted entered value, 0 if canceled editing. The val is entered or chosen value if save = 1. For save=0 is val null.
Return true to continue editing, only if save is 1. For save = 0 the finish cannot be suppressed.
To change edited value you should rather use event OnValueChanged, except you want to convert raw value to val. Also see OnAfterValueChanged event.
(Since 8.1) The raw value is exact not converted string entered by a user. For Enum type is always the same as val.
(Since 10.0) You can return new value to be used instead of val. The return value type must be string or number, should be the same as type of val.
Use for custom converting the raw string value to the cell value. Only if save is 1.
You can return original value by Get(row,col) to ignore the input and finish editing.
API event type

OnCustomStartEdit

(TGrid grid, TRow row, string col, string val, HTMLElement cell, int width)
Use this event to create and manage your own editing control.
Called before starting editing to display the custom editing control.
val is formatted string to be displayed in edit control, cell is cell object that should be used as parent of the custom editing control, width is inner width of the cell.
If displayed custom editing control, return any nonull value - this value will be passed to OnCustomEndEdit event to let you to delete the custom edit control.

For example to use ExtJS basic TextField editing component use such framework:
Grids.OnCustomStartEdit = function(G,row,col,val,cell,width){ var I = new Ext.form.TextField({ value: val }); I.render(cell); I.focus(); I.selectText(); return I; }
Grids.OnCustomEndEdit = function(G,row,col,save,I){ var val = I.getValue(); I.destroy(); return val; }
API event string

OnCustomEndEdit

(TGrid grid, TRow row, string col, bool save, type custom)
Use this event to delete your own editing control and save its value.
Called to finish editing by custom edit control returned by OnCustomStartEdit.
save is 1 when value will be changed (user accepted editing), otherwise it will be ignored. custom is the object returned by OnCustomStartEdit.
Return new value to save or null to not save even if save parameter is 1.
chg 6.0 API event string

OnGetInputValue

(TGrid grid, TRow row, string col, string val)
Called to convert or update cell value to string for input.
Called before the value is set to <input> or <textarea> on start edit.
Return converted or original value val.
API event string

OnSetInputValue

(TGrid grid, TRow row, string col, string val)
Called to convert or update input string back to cell value.
Called before OnValueChanged, but only for cells edited by <input> or <textarea>
Return converted or original value val.
upd 12.0 API event bool

StartEdit

(TRow row = null, string col = null, bool empty = 0, bool test = 0)
Starts editing in the focused cell. The focused cell can be set grid.Focus ( ) and read by grid.FRow, grid.FCol
Starts editing only in textual cell by <input> or <textarea> or shows Enum list.
row, col (new 11.0) can be set to edit different cell than actually focused cell.
If empty (new 11.0) is set to 1, clears the input cell value on start.
Returns true for success and false if fails.
Since 12.0 if set test, does not do anything, just checks the possibility.
upd 6.0 API event int

EndEdit

(bool save)
Finishes / cancels editing in the edited focused cell.
If save is true, saves changed value, if save is 0, discards changes and restores original value.
Returns 1 if value has changed, 0 if value has not changed, -1 to continue editing (editing cannot be finished, only for save = 1), null for error (not in edit mode).
new 13.0 API event string

GetStringEdit

(TRow row, string col)
Returns cell value as string for editing. If the cell contains EFormula, it returns the EFormula starting by '='.
new 13.0 API event void

SetStringEdit

(TRow row, string col, string value, bool timeout = 1)
Sets the cell value like it was entered in cell editing, if the value starts by '=', it sets cell EFormula.
It starts editing, puts the value to the cell and finishes editing. So by default it is called in asynchronously in setTimeout.
To call it synchronously set timeout = 0, in this case it must not be called from TreeGrid event handler, especially not from OnEndEdit.
<Actions>

StartEdit

Attached to many events
Starts editing focused cell.
It fails if the cell cannot be edited or there is no focused cell or some cell is already being edited.
By default it is attached to events OnClickCell, OnClickEnum, OnDblClickCell, OnKey, OnBackSpace, OnEnter, OnF2, OnTabEdit, OnShiftTabEdit, OnTabEnum, OnShiftTabEnum, OnUpEdit, OnDownEdit.
See also InEditMode settings.
new 11.0 <Actions>

StartEditEmpty

Attached to events OnKey and OnBackspace
Starts editing focused cell.
The same as StartEdit, but the cell value is always empty on start editing.
new 11.0 <Actions>

StartEditCell

Not attached to any event
Starts editing actual cell under mouse cursor.
It does not move the focus cursor, so the cell is edited outside the focus cursor.
It fails if the cell cannot be edited or there is no cell under mouse cursor or some cell is already being edited.
new 11.0 <Actions>

StartEditCellEmpty

Not attached to any event
Starts editing actual cell under mouse cursor.
The same as StartEditCell, but the cell value is always empty on start editing.
new 13.0 <Actions>

StartEditCellAccept

Attached to OnClick event to Toolbar cell Size
Starts editing actual cell under mouse cursor.
Finishes previous editing. If edited the same cell, does not start editing again.
new 13.0 <Actions>

StartEditCellEmptyAccept

Not attached to any event
Starts editing actual cell under mouse cursor.
The same as StartEditCellAccept, but the cell value is always empty on start editing.
<Actions>

AcceptEdit

Attached to events OnEnterEdit, OnCtrlEnterEdit, OnAltEnterEdit
Ends editing, saves changed value, returns true when editing was finished, even if value was not saved.
Changes are automatically accepted also by any change of focus by navigation actions - if you want to discard changes, call CancelEdit first.
It fails if the grid is not in edit mode or editing was not finished.
<Actions>

CancelEdit

Attached to event OnEscEdit
Cancels editing, discards changes, returns true when editing was finished.
It fails if the grid is not in edit mode or editing was not finished.

Controlling INPUT tag by JavaScript

new 9.0 <C> <cell> string

Edit

JSON settings for inline editing. It contains JSON definition of TEdit object.
new 9.0 TEdit event void

OnStartEdit

( )
Called when the TEdit object is created.
The TEdit object is accessible by this, the <input> tag by this.Tag.
The grid is accessible by this.Grid, the actual cell by this.Grid.Row and this.Grid.Col.
Example: <C Name="A" Edit=" { OnStartEdit: function() { this.Tag.className='MyInput'; } } "/>
new 9.0 TEdit event void

OnChange

(string Value, string Old)
Called after every change done while editing. Called for every key up or suggest select.
The Value is already shown in the input. Old is old value before change.
The TEdit object is accessible by this, the <input> tag by this.Tag.
The grid is accessible by this.Grid, the actual cell by this.Grid.Row and this.Grid.Col.
Example: <C Name="A" Edit=" { OnChange: function(V) { alert('Value '+V+' in column '+this.Grid.FCol); this.Tag.focus(); } } "/>
new 9.0 TEdit event void

OnKeyDown

(string key, Event event, bool handled)
Called after holding key down while editing.
It is called after functional keys like enter or esc are processed.
key is keyCode / charCode, event is standard JavaScript MouseEvent.
handled is true, if the event will be cancelled and the key will not be used in the input.
The TEdit object is accessible by this, the <input> tag by this.Tag.
The grid is accessible by this.Grid, the actual cell by this.Grid.Row and this.Grid.Col.
Example: <C Name="A" Edit=" { OnKeyDown: function(key,event) { if(key==65) CancelEvent(event); } } "/> (restricts entering 'a' key)

Input validation and restrictions

Editing masks can be used for any column type.
For column types Int, Float and Date are predefined default editing masks. These masks can be also changed using following attributes.
<C> <cell> int

Size

Maximal count of characters permitted to enter in <input> tag, not used for <textarea> (Lines type). For textarea implement EditMask or ResultMask.
It sets <input maxLength/> attribute.
<C> <cell> string

EditMask

Mask for editing. It can be any regular expression (JavaScript RegExp string).
This is mask is checked during editing. If a user presses a key, the resulted text is checked with the mask. If the new text does not pass the mask, the cell blinks and the previous text is restored.
The mask is checked by JavaScript text.search(EditMask)>=0.
Examples of editing masks: without spaces: "^\S*$", only digits: "^\d*$", only alphanum chars: "^\w*$", max 10 digits: "^\d{0,10}$"
Remember, some validation should be done rather by ResultMask to not complicate editing - you should for example permit empty string in EditMask even if the input is required - it can be rejected by ResultMask. Or structure validations like URL, email or telephone number should be fully tested by ResultMask and by EditMask just test only applicable characters.

By EditMask you can also define some exact text structure and let user to change only some parts of it.
For example EditMask="^Src:.*\r?\nw\:\d{0,3},h\:\d{0,3};\sx\:\d{0,4},y\:\d{0,4}$"
displays (in textarea, always on two rows):
Src:[text]
w:[int],h:[int]; x:[int],y:[int]

where [...] are the only editable sections, [text] can contain any characters, [int] can contain only digits, max 3 or 4.

Remember, default cell value must always pass the EditMask, otherwise a user will not be possible to edit it.
<C> <cell> string

MaskColor

['red']
The edit field blinks by this color, when user tried to write character conflicting with EditMask.
It can be color name or any other CSS color setting.
<Cfg> bool

Silent

[1]
If set to 0, the grid beeps on error.
It is not supported on all browsers and also on some browsers it can required a plugin to download.
<C> <cell> string

ResultMask

Validation mask applied after finish editing or when validate cells on save. Syntax is the same as in EditMask.
When input value collides with ResultMask, the ResultText alert message is displayed and editing continues.
Examples of result masks:
number range 0 - 255: "^([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])$"
floating point number: "^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$"
email address: "^[\w\.\+%-]+@[A-Za-z0-9\.-]+\.[A-Za-z]{2,6}$"
credit card VISA: "^4[0-9]{12}(?:[0-9]{3})?$"
credit card MasterCard: "^5[1-5][0-9]{14}$"
<C> <cell> string

ResultText

Alert message displayed when value collides with ResultMask.
If not set (default), the alert message is not displayed and editing just continues without accepting the input.
new 7.0 <C> <cell> string

ResultMessage

HTML message displayed as modal TreeGrid message when value collides with ResultMask.
If not set (default), the message is not displayed and editing just continues without accepting the input.
The message can be automatically hidden after ResultMessageTime milliseconds.
new 7.0 <C> <cell> int

ResultMessageTime

How long will be the ResultMessage shown, in milliseconds.
If not set or set to 0, the message is shown forever with OK button to hide it.
If set to negative number, the message is shown for the (positive) time, but also with OK button to hide it.
upd 12.0 API event int

OnResultMask

(TGrid grid,TRow row, string col, string val, object error)
Called when entered value collides with ResultMask.
Return 0 - alert ResultText message and continue editing,
1 - don't alert the ResultText message and continue editing,
2 - don't save value and finish edit,
3 - save value and finish edit
4 - (new 12.0)save value, finish edit and set the cell Error attribute to ResultText
error object is set only when changing more cells at once, e.g. by pasting, see OnEditErrors API event.
chg 6.0 upd 12.0 <Cfg> string[]

Validate

If and how will be validated all result masks (ResultMask) before changes are uploaded to server on save. Comma separated list of keywords.
For custom validation you can use also OnValidate API event.
AddedValidates only added new rows, to ensure that all new added rows are filled correctly.
Changed(Since 9.1) Validates also changed rows, to ensure that all modified rows are filled correctly.
AllValidates all rows in grid, to ensure that all required inputs are filled correctly - it can be slow for large grids.
ConfirmOn error displays confirm message and let a user to continue or not, otherwise it displays alert and cancels saving.
FocusOn error focuses the first invalid cell.
EditOn error starts editing the first invalid cell.
TextOn error inserts ResultText before ValidateText in alert or confirm message.
Messages(new 12.0) It shows all error messages in the dialog or confirm message. Ignores Text flag.
Processes the edit errors and shows them in the message, see OnEditErrors API event.
NoErrorDoes not set Error attribute and color for invalid cells.
Error(new 12.0) Takes as error all cells with Error attribute set.
There must be set keyword All or Added to do the validation.
On error calls OnValidateError event and displays alert or confirm message with ValidateText and colors invalid cells.
Not used for AutoUpdate.
<Cfg> string

ValidateText

Alert or confirm message displayed for error in validation on save.
new 7.0 <Cfg> string

ValidateMessage

Alert or confirm HTML message displayed by TreeGrid message for error in validation on save.
The message can be automatically hidden after ValidateMessageTime milliseconds.
If Validate contains Confirm keyword, this message is shown in standard confirm dialog.
new 7.0 <Cfg> int

ValidateMessageTime

How long will be the ValidateMessage shown, in milliseconds.
If not set or set to 0, the message is shown forever with OK button to hide it.
If set to negative number, the message is shown for the (positive) time, but also with OK button to hide it.
<cell> string

Error

If set it means that the cell contains invalid value.
The cell is colored red and as tool tip is displayed the Error string.
The Error attribute is set by Validate on save and it is cleared after cell value changed.
It can be returned also from server in on server validation. In this case the server should also clear it after successful upload in next response.
upd 12.0 API event bool

OnValidate

(TGrid grid, TRow row, string col, bool err, object errors)
It is called for every cell to validate its value on saving, only if set Validate attribute.
The err is error result of ResultMask validation, if any, otherwise 0.
Return 0 ok, 1 error.
(Since 12.0), for errors see OnEditErrors API event.
API event int

OnValidateError

(TGrid grid, TRow[] row, string[] cols)
Called on validation error when saving. When set Validate attribute.
Return0 - alert or confirm message and cancel or continue saving, depending on user confirmed the saving or not
1 - cancel saving, no alert shown
2 - continue saving, no alert shown
rows and cols are invalid cells that do not match their ResultMask.
<Actions>

Validate

Attached to event OnClickButtonSave
Validates data according to settings in Validate.

Side checkbox

Checkbox displayed usually in tree in main column between tree and cell text.
It has two direct states 0 unchecked and 1 checked.
Parent row shows state of its children. It shows 1 checked if all children are checked, 0 unchecked if all children are unchecked and 2 unknown if there are both the checked and unchecked children.
On click to parent checkbox it changes all child values to 1 checked or 0 unchecked.

If the cell is not editable, the icon is checked / unchecked by click to any part of the cell. To check / uncheck the icon still only by clicking to icon itself, set:
<Actions OnClickSideCheck="" OnDblClickSideCheck=""/> (to disable the original actions called for the whole cell click)
and to your column or cell add the actions like: <C ... OnClickSide="Focus,SetChecked" OnDblClickSide="SetChecked" ... />
new 9.3 <C> <cell> string

Icon

["Check"]
To show left side checkbox set Icon="Check".
It can be set also as right side button by Button="Check".
new 9.3 <cell> int

Checked

[0]
Value for Icon="Check".
0 - unchecked, 1 - checked, 2 - unknown

To upload this value to server define new column <C Name="XXXChecked" Visible="0" CanHide="0"/>, where XXX is name of the column with the Icon="Check".
new 9.3 <Actions>

SetChecked ...F

Attached to event OnClickSideCheck
Called on click to the Check icon, changes the Checked attribute / icon state to 0 / 1. It updates also all related parent and child Checked states.
new 12.0 <Actions>

CheckIcon ...F

Not attached to any event
Sets the focused or actual cell Checked attribute to 1, only if the cell has Icon="Check". It updates also all related parent and child Checked states.
new 12.0 <Actions>

UncheckIcon ...F

Not attached to any event
Sets the focused or actual cell Checked attribute to 0, only if the cell has Icon="Check". It updates also all related parent and child Checked states.
new 9.3 API method void

SetChecked

(TRow row, string col, int value)
Changes the state of given Check icon / Checked attribute. It updates also all related parent and child Checked states.
If row is null, it changes all checkboxes in the column to the value. In this case value can be 0 or 1.
col is the column with the Check icon / Checked attribute.
value can be 0 or 1 to set this value. If value is null, it changes the Checked state from 2 or 1 to 0 and from 0 to 1. value should not be 2.
new 9.3 API method void

ResetChecked

(TRow row, string col)
Updates this checkbox value according to its children. Updates also the children in the deep levels.
Call it in OnLoaded like Grids.OnLoaded = function(G){ G.ResetChecked(); } if you want to specify only leaf rows' Checked value to '1' to calculate all the parent values.