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.
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.
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).
<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. Except value '1' if set in default row.
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.
Dynamic editing
Since 15.0 there was added attribute DynamicEditing and its default value 0 disables the actions for changing editing permissions!
new 15.0 <Cfg> int
DynamicEditing
[0]
Permits changing editing permissions by users.
0 - off,
1 - for variable rows and middle columns only
2 - for all rows and columns.
If set, permits the actions SetEditable..., SetReadOnly..., SetPreview... and ClearEditable...
If not set, the
Locked flag
Edit affects only cells without explicitly set CanEdit attribute.
new 12.0 <Actions>
SetEditable ...FSARCWO
Not attached to any event
Sets 1 to cell attribute
CanEdit in actual or focused cell or in all focused or selected cells or rows or columns.
new 12.0 <Actions>
SetReadOnly ...FSARCWO
Not attached to any event
Sets 0 to cell attribute
CanEdit in actual or focused cell or in all focused or selected cells or rows or columns.
new 12.0 <Actions>
Not attached to any event
Sets 2 to cell attribute
CanEdit in actual or focused cell or in all focused or selected cells or rows or columns.
new 12.0 <Actions>
ClearEditable ...FSARCWO
Not attached to any event
Clears cell attribute
CanEdit in actual or focused cell or in all focused or selected cells or rows or columns.
new 12.0 deleted 15.0 <Actions>
SetEditableCells
,
SetEditableSelected
SetEditableRow
,
SetEditableRows
,
SetEditableSelectedRows
SetEditableCol
,
SetEditableCols
,
SetEditableSelectedCols ...F
Not attached to any event
Replaced by
SetEditable action.
new 12.0 deleted 15.0 <Actions>
SetReadOnlyCells
,
SetReadOnlySelected
SetReadOnlyRow
,
SetReadOnlyRows
,
SetReadOnlySelectedRows
SetReadOnlyCol
,
SetReadOnlyCols
,
SetReadOnlySelectedCols ...F
Not attached to any event
Replaced by
SetReadOnly action.
new 12.0 deleted 15.0 <Actions>
SetPreviewCells
,
SetPreviewSelected
SetPreviewRow
,
SetPreviewRows
,
SetPreviewSelectedRows
SetPreviewCol
,
SetPreviewCols
,
SetPreviewSelectedCols ...F
Not attached to any event
Replaced by
SetPreview action.
new 12.0 deleted 15.0 <Actions>
ClearEditableCells
,
ClearEditableSelected
ClearEditableRow
,
ClearEditableRows
,
ClearEditableSelectedRows
ClearEditableCol
,
ClearEditableCols
,
ClearEditableSelectedCols ...F
Not attached to any event
Replaced by
ClearEditable action.
Locking
new 15.0 <Cfg> string[]
Locked
[""]
If and what is locked (not changeable) in the grid, comma separated list of flags, case insensitive.
Layout | Locks rows and columns - adding, deleting, moving, resizing, manual showing and hiding.
Individual flags:
AddRow - adding new rows, DelRow - deleting rows, AddCol - adding new column, DelCol - deleting columns,
MoveRow - dragging rows (including indent), MoveCol - dragging columns, IndentCol - indent columns,
ResizeRow - changing row height, ResizeCol - changing column width,
ResizeSection - changing width of column section, ResizeGrid - changing width and height of the grid main tag,
HideRow - manual show / hide rows, HideCol - manual show / hide columns,
FixRow - freeze row to top or bottom, FixCol - freeze column to left or right,
Tab - Tab type cell manipulation.
Changing columns & rows visibility via menu and by filter / search is controlled by flag State -> Visibility. |
Edit | Locks cell values. Cell values are in read only mode, like Editing = 2. Including Gantt objects manipulation.
Includes tags: EditLink - adding, changing, deleting links from cells, EditImg - adding, modifying and deleting images from cells.
|
CanEdit | Ignores cell CanEdit attribute.
If set, the flags Edit and Style lock / unlock all cells for editing regardless on their own editing permissions / restrictions set by CanEdit attribute.
If not set, the flag Edit locks only cells that have not set CanEdit=1 and the flags Edit and Style unlock only cells that have not set CanEdit=0.
Setting only "CanEdit" without "Edit" will permit editing not editable cells (only not editable by their attribute CanEdit='0').
|
PermitEdit | Suppresses changing cell CanEdit attribute.
|
Focus | Permits focus only on editable cells |
Style | Locks dynamic cell style, border, row and column span. Locks it regardless on the CanEdit attribute value. |
Formula | Locks editable formulas. The formulas are never shown, in editing mode is shown cell empty value.
If set with flag Edit, in editing mode is shown cell actual value read only. |
State | Locks sorting, filtering, searching, grouping and menu column & rows visibility.
Individual flags: Sort, Filter, Search, Group, Visibility - changing rows and columns visibility via configuration menu.
|
Expand | Locks expanding and collapsing rows and columns. |
Zoom | Locks Gantt zoom. |
Sheet | Locks sheet manipulation - adding, deleting, renaming, moving and copying sheets in xlsx. |
Export | Locks exporting grid to xlsx/xls/csv. |
Copy | Locks copying row, columns and cells to clipboard. It still permits copying selected text during editing. |
Link | Suppresses links following. |
Select | Suppresses selecting cells, rows and columns. |
Save | Suppresses uploading changes to server. |
Reload | Suppresses reloading layout or data. |
Import | Suppresses opening / importing xlsx. |
Cfg | Locks configuration - via menu and grid style, size, scale, language.
Individual flags: Menu, Size - style, size and scale, Lang.
|
Print | Suppresses printing and export to PDF. |
Lock | Suppresses locking / unlocking - changing the Locked state. |
Data | Lock the grid data; group flag for flags: Layout, Edit, CanEdit, PermitEdit, Style, Expand, Sheet, Save. |
View | Lock the grid configuration; group flag for flags: State, Zoom, Cfg, Reload, Import. |
Read | Lock the grid from copying; group flag for flags: Export, Copy, Formula, Link. |
All | Lock the grid completely except for printing; group flag for flags: Data, View, Read, Select, Focus, Lock. |
For API it is JavaScript object with the flags in lower case as
flag :
1.
Only usable individual (not group) flags are listed.
It has also property
length as count of the flags.
It does not change anything in grid display (e.g. does not hide unused icons/buttons), except the Lock button icon on toolbar.
new 15.0 <Cfg> string[]
LockedAlways
Locked flags added to the
Locked to be always locked regardless on the chosen lock. Possible values are the same as in the
Locked.
It is preferred to LockedNever if both contain the same flags.
new 15.0 <Cfg> string[]
LockedNever
Locked flags deleted from the
Locked to be never locked regardless on the chosen lock. Possible values are the same as in the
Locked.
new 15.0 <Cfg> string[][]
LockedValues
[...]
Semicolon separated list of permitted values that can be set to
Locked attribute.
The first value should be for unlocked grid, the next values for various locks in grid.
Default value is "
;layout,sheet
;layout,sheet,style,formula
;layout,sheet,style,formula,edit,save".
The Lock icon on toolbar can have up to four states, to use this default icon the LockedValue should contain up to four values.
new 15.0 <Cfg> string
LockType
The lock (
Locked flag) that controls the cell editing.
If not set, it is "Filter" on Filter row, "Group" on Group row, "Search" on Search row, "Menu" on Toolbar/Topbar row or "Edit" on any other row.
new 15.0 <Actions>
Lock
Assigned to event OnClickButtonLock
Set next or first value from
LockedValues list to
Locked attribute.
new 15.0 <Actions>
Lock0
Not assigned to any event
Unlocks grid. Set the first value from
LockedValues list to
Locked attribute.
new 15.0 <Actions>
Lock1
Not assigned to any event
Set the first lock to grid. Set the second value from
LockedValues list to
Locked attribute.
new 15.0 <Actions>
Lock2
Not assigned to any event
Set the second lock to grid. Set the third value from
LockedValues list to
Locked attribute.
new 15.0 <Actions>
Lock3
Not assigned to any event
Set the third lock to grid. Set the fourth value from
LockedValues list to
Locked attribute.
new 15.0 API method void
SetLocked
(string lock)
Sets the value
lock to the
Locked.
new 15.0 API method int
GetLockedIndex
( )
Returns index in original
LockedValues where actual value of
Locked is placed. From 0.
If the Locked is not in LockedValues it returns the closest index.
If the LockedValues contains the same items due actual permissions, the second item is removed, but the indexes remain unchanged.
new 15.0 API event int
OnLock
(TGrid grid, int lock)
Called before the
Locked attribute value is changed to the
lock value.
Return true to suppress the change or a number to change the
lock or null for default behavior.
new 14.1 deleted 15.0 <Cfg> bool
Protected
Replaced by
Locked = "Edit".
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 '*':
*Date | After click on menu item it shows calendar to select date. |
*Button | After click on menu item it calls OnButtonClick user event for the cell. |
*Default | Item contains default value for the cell (value from Def row). |
*FilterOff | Switches off the filter operator, only for filter row. |
*All | Chooses all items for range. |
*None | Selects 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 ...FAO
Displays dialog
Defaults for the actual or focused cell.
new 12.0 <Actions>
ShowDefaultsMenu ...FAO
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
(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 upd 14.0 API method int
GetDefaultsIndex
(TRow row, string col, string val = null, int range = 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.
Since 14.0 if set
range or the cell has set
Range it returns all indexes for all values, semicolon separated. If set
range = -1, it returns them as an array.
Works only for simple defaults as first character separated array, without special items (*) and not as TreeGrid Menu.
new 6.0 upd 14.0 API method string
GetDefaultsValue
(TRow row, string col, int index, int range)
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.
Since 14.0 if set
range or the cell has set
Range it returns all values for all indexes, semicolon separated. If set
range = -1, it returns them as an array.
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:
Replace | if set, replaces the actual edit input while changing selected item in the suggest menu by cursor keys |
Start | if 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 |
Empty | if set, shows the full suggest menu also for empty input value |
All | if 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 ",.;".
If used with EHtml type, it removes HTML formatting!
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.
Tags input
Entering individual tags visually marked and separated.
Usually used along with
Suggest.
new 16.0 <C> <cell> int
Tags
If the cell splits its value to separated marked tags.
If set to
2, it shows delete 'x' icon and permits deleting tags by mouse click to the 'x' icon.
new 16.0 <C> <cell> string
TagsType
Various settings for
Tags. Comma separated list of keywords, case insensitive:
Unique | if set, it removes duplicate tags after edit. |
Sort | if set, the tags are sorted ascent after edit. |
Lower | if set, the tags are converted to lower case after edit. |
Upper | if set, the tags are converted to upper case after edit. |
Edit | if set, the cell is set to edit mode after added new tag and pressed enter. |
Character that separates individual tags in the cell value.
By default it is set to ValueSeparator, it is semicolon by default.
It can be set also to LF ("
" in XML or "\n" in JSON) to display tags vertically.
new 16.0 <C> <cell> string
TagsEmpty
Text displayed next or under the last tag to inform user that the tags can be edited.
<C><I><cell> bool
Wrap
[0]
If set to
1 the tags are automatically wrapped to more lines if there is not enough room horizontally.
new 16.0 <Actions>
DeleteTag
Attached to OnClickTagDelete event
Deletes the clicked tag, attached to click to the tag 'x' icon.
new 16.0 <Actions>
StartEditEmptyDeleteTag
Attached to OnBackspace event
Starts editing the cell value empty and if called in Tags cell, it deletes the last Tag, if any.
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] 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.
API method void
SetCase
(TRow row, string col, bool lower, bool refresh = 0)
Changes cell value to upper case (
lower=0) or lower case (
lower=1).
new 15.0 <Actions>
Not attached to any event
Converts all characters to upper case in actual or focused cell or in all focused cells or in all selected cells.
new 15.0 <Actions>
Not attached to any event
Converts all characters to upper case in actual or focused cell or in all focused cells or in all selected cells.
Mass cell change
Changing values and attributes of more editable cells at once.
Name | Action | API | Description |
Actions affected by EditAttrs and EditErrors and calling OnEditAttrs, OnValueChanged, OnAfterValueChanged and OnEditErrors |
"Clear" | ClearCell + 23 more | ClearRange | Clear cell or cell range. Usually by pressing del key |
"Copy" | CopyFocus + 2 more | CopyRange | Copy focused cell range. Usually by mouse dragging |
"Move" | MoveFocus + 2 more | CopyRange | Move focused cell range. Usually by mouse dragging ("Copy"+"Clear") |
"Fill" | FocusFillRowCol +6 more | FillRange | Auto fill focused or dragged cell range. Usually by mouse dragging |
"Paste" | Paste | | Paste 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 upd 15.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,
3 (new 15.0) check & show message except on loading.
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:
Action | as 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
[2000]
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.
new 15.0 <Cfg> int
MaxMenuAllCells
[5000]
Maximum tested (selected / focused) cells that will be affected by mass change action.
If there are more cells to test, the action is always permitted.
Used to speed up testing if the action affects focused / selected cells.
new 15.0 <Cfg> int
MaxMenuAllCellsValue
[1000]
Returned count of cells affected by action if
MaxMenuAllCells limit is reached.
new 15.0 <C> <I> bool
NoData
[0/1]
If set, the column or row is not affected by mass changing values.
By default it is set to Header, Filter, Panel and ColTree rows and to Index, Panel and ConstWidth columns.
new 15.0 API variable
CellRanges
If set, affects all mass change actions, forces these actions to work on given ranges.
Set it before calling some mass change action to change given ranges and clear it after the call.
Should contain 2D array: [[row11,col11,row12,col12],[row21,col21,row22,col22],...]. The row or col parameters can be null for the whole rows or columns.
Clearing cells
new 12.0 chg 15.0 <Actions>
Not attached to any event
Clears value and all other
EditAttrs attributes in the focused or actual cell or in all focused cells or in all selected cells.
Sets the cell value to 0 in Int, Float and Date types (if CanEmpty is not set) or to empty string.
Sets all the attribute values to null.
Since 15.0 If the cell default attribute value or row / column attribute value is set, it sets the cell attribute value to empty string instead of null.
new 15.0 <Actions>
ClearValueStyle ...FSARCWO
Not attached to any event
Clears value and all other
EditAttrs attributes like action ClearCell, but fails if there is no cell with value and no cell with style to clear.
To be used aling with
ClearValue and
ClearStyle actions.
new 12.0 <Actions>
Not attached to any event
Clears value and EFormula in the focused or actual cell or in all focused cells or in all selected cells.. 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 upd 15.0 <Actions>
Attached to event OnClickButtonClearStyle
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
Since 15.0 If the cell default attribute value or row / column attribute value is set, it sets the cell attribute value to empty string instead of null.
Since 15.0 it can be called also during editing
EHtml type cell to clear style from selected text.
Since 15.0 it clears all CSS styles also from the
EHtml cell value.
new 12.0 deleted 15.0 <Actions>
ClearCells
,
ClearValues
,
ClearStyles ...F
Not attached to any event
Replaced by action
ClearCell
new 12.0 deleted 15.0 <Actions>
ClearSelectedCells
,
ClearSelectedValues
,
ClearSelectedStyles ...F
Not attached to any event
Replaced by action
ClearCell
new 12.0 deleted 15.0 <Actions>
ClearRow
,
ClearRowValues
,
ClearRowStyles ...F
Not attached to any event
Replaced by action
ClearCell
new 12.0 deleted 15.0 <Actions>
ClearSelectedRows
,
ClearSelectedRowsValues
,
ClearSelectedRowsStyles ...F
Not attached to any event
Replaced by
ClearCell
new 12.0 deleted 15.0 <Actions>
ClearCol
,
ClearColValues
,
ClearColStyles ...F
Not attached to any event
Replaced by action
ClearCell
new 12.0 deleted 15.0 <Actions>
ClearSelectedCols
,
ClearSelectedColsValues
,
ClearSelectedColStyles ...F
Not attached to any event
Replaced by
ClearCell
new 12.0 deleted 15.0 <Actions>
ClearAll
,
ClearAllValues
,
ClearAllStyles
Not attached to any event
Replaced by
ClearCell
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.
0 | the edit mode is run only when user clicks to already focused editable cell or double clicks some editable cell or presses Enter or F2. |
1 | the edit mode is run when user clicks to any cell or presses character key or Enter, F2 or Backspace. |
2 | the 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.
0 | Standard mode, Enter accepts value and do nothing else, no modification to OnEnter and OnEnterEdit. |
1 | Enter starts editing cell below, it sets <Action OnEnterEdit='AcceptEdit AND TabDownEdit,1' OnEnter='TabDownEdit'/> (chg 12.0) |
2 | Enter 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'/> |
3 | Enter starts editing cell right, it sets <Actions OnEnterEdit='AcceptEdit AND TabRightEdit,1' OnEnter='TabRightEdit'/> |
4 | Enter 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 (
). 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 (
). 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 (
). 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 15.0 <Cfg> int
EditCursor
[0]
Where to place caret on start editing.
0 - select the whole value.
1 - place caret to mouse/touch position and to the end on key action.
2 - place caret to the end of value.
3 - place caret to the start of value.
There are also attributes to preset only individual action:
EditCursorMouse (start editing by mouse click),
EditCursorTouch (start editing by finger touch),
EditCursorKey (start editing by key press),
EditCursorTab (editing tab, usually sheet name, by mouse or touch).
new 11.0 deleted 15.0 <Cfg> int
EditSelect
[7]
Replaced by EditCursor.
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 13.0 <Cfg> int
EditHtml
[4]
If and how the Html Type cell will be edited.
For Html edited by HTML editor use EHtml type instead.
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.
new 15.0 <Cfg> string[]
ExternalEdit
Can be set to cell as "rowid,col", usually in Space row, that will edit actually focused cell in table, only in Data row. Like the formula editing cell in MS Excel.
If focused any Data cell in grid, the external edit cell shows the focused cell value for editing.
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.
new 15.1 API event void
OnStartedEdit
(TGrid grid, TRow row, string col, object input)
Called after started editing of textual cell (in <input> or <textarea>) in given cell.
The
input is HTML input / textarea tag that will be used for input.
Use this event e.g. to turn off autocomplete in different way whenever Chrome changes its behavior.
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 be required a plugin to download.
new 13.3 <C> <cell> int
AcceptNaN
[1]
If the Int, Float or Date cell accepts entering incorrect value that cannot be converted to number or date.
What will be done if a user entered incorrect value:
0 - continue editing,
1 - alert error and continue editing,
2 - reject value and finish editing,
3 - reject value, finish editing and alert error,
4 - accept value and change it to
AcceptNaNValue,
5 - like 4 and alert error,
6 - ask a user if to accept (and change) the value or continue editing,
7 - ask a user if to accept (and change) the value or reject the change and finish editing,
8 - ask a user if to reject the value and finish editing or continue editing.
new 13.3 <C> <cell> type
AcceptNaNValue
[0]
The value that will be used instead of NaN value for
AcceptNaN = 4, 5, 6, 7.
If set to "NaN" the JavaScript NaN will be used.
new 13.3 <C> <cell> string
AcceptNaNText
The message text used for
AcceptNaN = 1, 3, 5, 6, 7.
new 13.3 <Cfg> int
AcceptNaNTime
[0]
Cfg attribute! How long, in ms, the
AcceptNaN = 1, 3, 5 message will be displayed. 0 means forever with OK button.
<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 16.2 <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.
Added | Validates 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. |
All | Validates all rows in grid, to ensure that all required inputs are filled correctly - it can be slow for large grids. |
Confirm | On error displays confirm message and let a user to continue or not, otherwise it displays alert and cancels saving. |
Focus | On error focuses the first invalid cell. |
Edit | On error starts editing the first invalid cell. |
Text | On 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. |
NoError | Does not set Error attribute and color for invalid cells. |
Error | (new 12.0) Takes as error all cells with Error attribute set. |
ClearError | (new 16.2) Clears Error attribute in all iterated valid cells. |
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.
Return | 0 - 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" ... />
To use the checkbox as simple on/off without checking its children set
<Actions
OnClickSideCheck="Focus,Grid.SetAttribute(Row,Col,'Checked',!Is(Row,Col+'Checked'),1),1"
OnDblClickSideCheck=""
/>
.
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 ...FAO
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 ...FAO
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 ...FAO
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.