Undo & Redo

TreeGrid documentation

upd 12.0 <Cfg> int

Undo

[0]
Which changes can be undone and redone by Undo/UndoAll and Redo/RedoAll actions, by default for CtrlZ and CtrlY events. Bit array.
1.bit&1All changes (change cell value, delete row, add row, move row, copy row)
Does not affect changes in Filter row and rows with NoUpload='1' (by default Group, Search, Tabber, Toolbar)
(new 12.0) Also adding and deleting columns.
(new 7.0) Next modifications are change Def by ChangeDef, change attribute by SetAttribute.
(new 7.0) If set <Cfg DynamicSpan='1'/>, also span cell, split cell and move column can be undone.
(new 12.0) If set <Cfg DynamicBorder='1'/>, also cell border change can be undone.
2.bit&2(new 11.0) Selecting rows and cells. More selection changes done subsequently are undone at once, including Focusing cells.
3.bit&4(new 11.0) Focusing cell(s). More focus changes done subsequently are undone at once, including Selecting cells.
4.bit&8(new 11.0) Resizing rows, columns, sections and grid. Moving columns.
(new 12.0) Also showing / hiding rows and columns.
5.bit&16(new 11.0) Features (filter cell and operator change, sort change, search action change except Find and Help actions).
Note, rows cannot be sorted into original state if no Sort was defined on grid load.
The group change and search expression change is covered by undo cell change. Set NoUpload='0' to these rows to provide undo.
Cannot be used in server paging (Paging=3).
6.bit&32(new 11.0) Undo can go beyond saved (accepted) changes.
If set AutoUpdate, every undone or redone change is uploaded to server immediately.
Incompatible with GanttRunStates.
7.bit&64(new 12.0) Also scroll, both vertical and horizontal

TreeGrid buffers all modifications since last save or reload. For server paging the buffer is cleared by any action reloading body like sort or filter.
Undo undoes the last unsaved modification and it is disabled with AutoUpdate except if is set the 6th bit (&32).
new 12.0 <Cfg> string[*][ ]

UndoMerge

[ ]
Which undo actions will be merged and undone at once.
It is two dimensional array, the first dimension (groups) is first character separated, the second dimension (actions) is comma separated. Like "|action11,action12,...|actions21,actions22,...|..."
All actions in one group will be merged, if there is no other action between them. No action can be in more groups.
To merge always all actions of the same type, place one empty group, like "||action11,action12,...|..."
For example UndoMerge="|Focus,Select,Scroll|ColsVisibility|Filter" means to merge Focus,Select and Scroll actions. To merge all actions of type ColsVisibility and to merge all actions od type Filter.
The undo actions are listed in OnUndo.
upd 11.0 <I> int

NoUpload

[0/1]
If set to 1, ignores changes in this row and does not upload them to server.
If set to 1, it also does not save undo for changed cells except the cell has set Undo='1'.
(Since 11.0) If set to 2, it works like 1 and if the row contains some pending changes, they are not accepted after save.
Default value is 0 for data rows and 1 for space rows.
Filter row has always set 1.
new 6.4 <cell> bool

Undo

[0/1]
If the change in cell will be saved to undo list and can be undone.
By default it is set 1 for data rows and 0 for space rows. Exactly default value is set to !NoUpload.
Filter row cells have always set 0.
<Actions>

Undo

Attached to event OnCtrlZ and OnClickButtonUndo
Undoes the last grid modification (cell change, add row, delete row(s), move row(s), copy row(s)).
<Actions>

UndoAll

Not attached to any event
Undoes all modifications done since last save or accepting changes or reloading body or grid.
<Actions>

Redo

Attached to event OnCtrlY and OnClickButtonRedo
Does again the last undone action. It can be done only when between Undo and Redo was not done any other modification.
<Actions>

RedoAll

Not attached to any event
Does again all undone actions. It can be done only when between Undo and Redo was not done any other modification.
<Actions>

ClearUndo

Not attached to any event
Clears undo buffer.
Remember, the undo buffer is cleared automatically on save (except 6. bit of Undo is set) or reload or reload body.
new 6.3 API method bool

CanUndo

( )
Returns true, if there is something to undo.
new 6.3 API method bool

CanRedo

( )
Returns true, if there is something to redo.
new 7.0 API method void

StartUndo

( )
Starts new undo block.
Call it before doing more changes in grid to be undone all at once
The undo blocks can be nested. But the count of calling StartUndo must be the same as count of calling EndUndo.
new 7.0 API method void

EndUndo

( )
Ends new undo block.
Call it after doing more changes in grid to be undone all at once.
API method void

ClearUndo

(bool recalc)
Clears undo buffer.
Remember, the undo buffer is cleared automatically on save or reload or reload body, except Undo has set flag 32.
If set recalc, it recalculates the space rows to refresh toolbar buttons.
new 7.0 API method void

CustomUndo

(object Object, function Undo, function Redo)
Adds into undo queue custom undo action.
The Object should contain all information you require to do both undo and redo actions.
On undo is called Undo(Object), on redo is called Redo(Object). Or is possible also to use OnUndo / OnRedo API events.
new 11.0 API method void

MergeUndo

(string type1 = null, string type2 = null)
Merges two last blocks of undo to one.
If set type1 it merges the blocks only if the older block contains undos only of types type1 or type2.
new 7.0 upd 12.0 API method void

OnUndo

(TGrid grid, string action, .... )
Called after given action is undone by clicking Undo button or Ctrl + Z. action:
"Start"OnUndo (TGrid grid, string action)Called before block of undo actions starts, but undo is already disabled
"End"OnUndo (TGrid grid, string action)Called after block of undo actions finishes, but before undo is enabled
"Change"OnUndo (TGrid grid, string action, TRow row, string col, type value)After cell changed to original value. value is previous value
"EFormula"OnUndo (TGrid grid, string action, TRow row, string col, type value)After cell formula changed to original value. value is previous value
"Add"OnUndo (TGrid grid, string action, TRow row, TRow src)After added or copied row is deleted, but before it is removed
"Delete"OnUndo (TGrid grid, string action, TRow row)After deleted row is undeleted or undeleted row is deleted
"Move"OnUndo (TGrid grid, string action, TRow row, TRow parent, TRow next)After moved row is moved to original position
"Show"OnUndo (TGrid grid, string action, TRow row)After row is hidden (new 12.0, if set Undo&8)
"Hide"OnUndo (TGrid grid, string action, TRow row)After row is shown (new 12.0, if set Undo&8)
"Span"OnUndo (TGrid grid, string action, TRow row1, string col1, TRow row2, string col2)After spanned cell is split back (if set DynamicSpan='1')
"Split"OnUndo (TGrid grid, string action, TRow row1, string col1, TRow row2, string col2)After split cell is spanned back (if set DynamicSpan='1')
"AddCol"OnUndo (TGrid grid, string action, string col, TCol C)After added column is removed (new 12.0)
"DeleteCol"OnUndo (TGrid grid, string action, string col, int del, TCol C)After column is deleted or undeleted (new 12.0)
"MoveCol"OnUndo (TGrid grid, string action, string col, string tocol, string rightcol)After moved column is moved back to original position (if set DynamicSpan='1' or Undo&8)
"ColsVisibility"OnUndo (TGrid grid, string action, string[ ] show, string[ ] hide)After columns are hidden or shown (new 12.0, if set Undo&8)
"ChangeDef"OnUndo (TGrid grid, string action, TRow row, string def)After row Def attribute is changed back to original value
"SetAttribute"OnUndo (TGrid grid, string action, TRow row, string col, string attr, type value)After the attribute set by SetAttribute method changed to original value
"CopyAttrs"OnUndo (TGrid grid, string action, TRow row, string col, string attrs[ ], type values[ ])After the attributes changed due CopyAttrs changed to original value (new 12.0)
"GanttBase"OnUndo (TGrid grid, string action, string base, string col)After GanttBase is moved back to original position
"GanttFinish"OnUndo (TGrid grid, string action, string finish, string col)After GanttFinish is moved back to original position
"Focus"OnUndo (TGrid grid, string action, TRow row, string col, int pagepos, type[ ] Rect)After moved focus back to original position (new 11.0, if set Undo&2)
"ResizeRow"OnUndo (TGrid grid, string action, TRow row, int height)After resizing row back to original height (new 11.0, if set Undo&8)
"ResizeCol"OnUndo (TGrid grid, string action, string col, int width)After resizing column back to original width (new 11.0, if set Undo&8)
"ResizeSec"OnUndo (TGrid grid, string action, int Left, int Mid, int Right)After resizing sections back to original widths (new 11.0, if set Undo&8)
"ResizeMain"OnUndo (TGrid grid, string action, int Width, int Height)After resizing grid main tag to original size (new 11.0, if set Undo&8)
"Select"OnUndo (TGrid grid, string action, TRow row, string col, bool select)After selecting cell (col!=null), row (row!=null) or all rows to original selection state (new 11.0, if set Undo&4)
"Filter"OnUndo (TGrid grid, string action, TRow row, string col, string value, int operator, bool hasoperator)After changing filter cell value or operator back to original value (new 11.0, if set Undo&16)
"Sort"OnUndo (TGrid grid, string action, string sort)After changing sort setting back to original value (new 11.0, if set Undo&16)
"Search"OnUndo (TGrid grid, string action, string action)After changing search action back to original value (new 11.0, if set Undo&16)
"Filtered"OnUndo (TGrid grid, string action, bool filtered)After changing Filtered value back to original value (new 11.0, if set Undo&16)
"Sorted"OnUndo (TGrid grid, string action, bool sorted)After changing Sorted value back to original value (new 11.0, if set Undo&16)
"Searched"OnUndo (TGrid grid, string action, bool searched)After changing Searched value back to original value (new 11.0, if set Undo&16)
"Grouped"OnUndo (TGrid grid, string action, bool grouped)After changing Grouped value back to original value (new 11.0, if set Undo&16)
"Scroll"OnUndo (TGrid grid, string action, int vscroll, int hscrollleft, int hscrollmid, int hscrollright)After grid is scrolled (new 12.0, if set Undo&64)
"Custom"OnUndo (TGrid grid, string action, object Object)After undo of custom undo set by CustomUndo
new 7.0 upd 12.0 API method void

OnRedo

(TGrid grid, string action, .... )
Called after given action is redone by clicking Redo button or Ctrl + Y. action and parameters are the same as in OnUndo.