Row and column manipulation
FastGrid documentation
API to get grid objects
Grid method Row
GetRow
(string id)
Returns row according to its
id.
Grid method bool
IsRow
(object row)
Returns true if the
row is
Row object.
Grid method Row
GetCol
(string id)
Returns column according to its
id.
Grid method bool
IsCol
(object col)
Returns true if the
col is
Col object.
Grid method string
GetPart
(object obj)
Returns
id of part that the row, column, toolbar or toolbar cell belongs to.
Grid method int
GetPos
(object item)
Returns row, column or toolbar position inside its part.
Grid method Grid
GetGrid
(object obj)
Returns grid that the row, column, toolbar or toolbar cell belongs to.
FGrid function Grid
GetGrid
(string / object tag)
FGrid function! Returns grid displayed in given main
tag (the <
fast-grid> or the tag passed to
FastGrid() call).
For book it returns active sheet in the book.
The
tag can be the HTMLElement or its id.
Or the
tag can be row, column, toolbar or toolbar cell object and the function returns the grid the given object belongs to.
Automatically added empty columns and rows on scroll
If set, automatically adds new empty columns or rows to the end of the part when scrolling to the end.
It also automatically removes empty columns or rows from the end when scrolling back to beginning.
It ensures that the part has always active scrollbar - its content is wider / higher than its width / height.
If set, it is maximum of empty columns / rows the grid can have added by
Auto. When the grid reaches this maximum, no new empty columns / rows are added.
Default value is 1,048,576 for
Body rows in xlsx sheet or 3,000,000 for
Body rows in other grids.
Default value is 16,384 (as XFD column) for
Cols columns in xlsx sheet or 475,254 (as ZZZZ column) for
Cols columns in other grids.
Default value for other parts than
Body and
Cols is not set, but should be set when setting
Auto for this part.
Default values smaller for xlsx sheet are set for compatibility with MS Excel.
Decreased by items count in
NextPart /
PrevPart chain.
If set, it is minimum of empty columns / rows the grid can have by
Auto. When the grid reaches this minimum, no unused empty columns / rows are deleted.
Decreased by items count in
NextPart /
PrevPart chain.
Which automatically added rows / columns will be removed when removing empty rows / column for
Auto.
It never removes rows / columns up to focused cell / cell range.
It can remove unchanged rows / columns (without any changed cell value and attribute) and / or if changes are not stored, rows / columns without values in
V and
A attributes.
0 - none,
1 - unchanged and without
V and
A,
2 - unchanged and without
V,
3 - unchanged or without
V and
A,
4 - unchanged or without
V,
5 - unchanged,
6 - all
&
8 - removes also not automatically generated columns. Use in xlsx where defined more empty rows / columns on the end.
&
16 - removes also focused cell / cell range.
Ignored in AutoRemove, used only in AutoIgnore... attributes.
&
32 - does not remove rows / columns with empty string values.
&
64 - does not remove rows / columns with empty string attribute values.
Default value is
11 for Body and Cols parts in Sheet, otherwise is
3.
Manipulating blocks of rows / columns together
Adjacent rows / columns with the same
Block value are manipulated, sorted and grouped together.
The rows / column in the
Block can be also filtered together, but can be also filtered individually.
Children of the rows / columns in the
Block can have the same
Block too, but they need not and the
Block is not broken down.
Rows / columns cannot be moved / copied / added into the block.
Rows / columns cannot be moved / copied individually outside their block.
Rows / columns cannot be deleted individually from the block.
Rows / columns cannot be sorted or grouped individually in the block.
Rows / columns can be moved individually inside the block.
Rows / columns can be hidden / shown individually in the block.
Rows / columns can be filtered individually in the block.
Row, Col string / int
Block
GetAttr
The
Block can be:
a)
id to the
Blocks. The row / column and the next rows / columns are modified by the chosen block from
Blocks on start. It overwrites the
Block in the next rows / columns. It reassigns the
Block by unique number.
b)
number (integer number, also in string). It merges to one block this row / column and next Block-1 rows / columns; it assigns to their
Block new unique number on start.
c)
string (not number). It is assigned as is only to this row / column.
Grid object[id]
Blocks
Blocks definition by their ids. Every block definition is array of objects.
These objects are copied to the rows / columns with
Block attribute that refers this block id.
Every the object can contain any row / column attributes, usually it contains the
D attribute.
The object can contain also
Add:
1 attribute, this object will create new row / column on its position.
For example:
Def: { R0: { ... }, R1: { Block:"B1" }, R2: { ... }, R3: { ... }, R4: { ... } }
Blocks: { B1: [ { D:"R0", Add:1 }, { /* Source row R1 */ }, { D:"R2" }, { D:"R3", Add:1 }, { D:"R4" } ] }
Body: [ {id:1}, {id:2, Def:"R1"}, {id:3}, {id:4}, {id:5} ]
will generate such result:
Body: [ {id:1}, {id:6, D:"R0", Block:20000001}, {id:2, D:"R1", Block:20000001}, {id:3, D:"R2", Block:20000001}, {id:7, D:"R3", Block:20000001 }, {id:4, D:"R4", Block:20000001 }, {id:5} ]
Grid method Row / Col
GetFirstBlock
(Row / Col item, int type = 0)
Returns the first row / column from the
Block where the item is. If the
item has not
Block attribute, returns it.
type&
1 - only visible.
Grid method Row / Col
GetLastBlock
(Row / Col item, int type = 0)
Returns the last row / column from the
Block where the item is. If the
item has not
Block attribute, returns it.
type&
1 - only visible.
Adding / copying / moving
If and how the grid permits adding and copying rows.
&
1 - permits adding new empty rows.
&
2 - permits copying existing rows.
If and how the grid permits adding and copying columns.
It is restricted by default.
&
1 - permits adding new empty columns.
&
2 - permits copying existing columns.
If and how the grid permits moving and copying rows by dragging.
&
1 - permits dragging inside its part.
&
2 - permits dragging between parts.
&
4 - permits dragging between grids.
If and how the grid permits moving and copying columns by dragging.
&
1 - permits dragging inside its part.
&
2 - permits dragging between parts.
&
4 - permits dragging between grids.
&
8 - permits dragging between different column sets.
Maximum rows / columns tested for moving / copying by actions
Add... to display the number in menu item.
Does
not affect real count of moved / copied rows / columns. It is used just to speed up showing the action menu for many selected rows.
Maximum cells tested for various actions like focus or border.
Does
not affect real count of affected cells. It is used just to speed up showing the action menu for many cells.
Controls showing drop icons during dragging, bit array:
&
1 =
1 displays the drop icons always next to the row / column under mouse.
0 - displays next drop icon after children to point to real drop place.
How much mouse or finger must be moved after button / touch down to start dragging, in pixels.
Various parameters for row dragging.
&
1 - if set, shows the ghost tag under mouse for whole row instead of for the cell under mouse.
&
2 - if set, the ghost moves only vertically on its column.
&
4 - if set, shows drop icons in column
Tree instead of headers.
&
8 - if set, permits dropping rows to next empty part by dropping the first / last row in part on its edge.
&
16 - if set, permits dropping rows to next empty part by dropping any row to the edge of the first / last row in part.
&
32 - if set, permits dropping rows to next empty part by dropping the row to the near unsuitable part (Toolbars / Scroll / Empty).
Shift the drag icon by given pixels to the right, for
MoveRowType&
4.
Various parameters for row dragging in tree.
&
1 - if set, drops rows as the last child instead of the first child.
&
2 - if set, expands row when dropped to its children.
&
4 - if set, expands row when dragging above its Collapse icon.
Various parameters for column dragging.
&
1 - if set, shows the ghost tag under mouse for whole column instead of for the cell under mouse.
&
2 - if set, the ghost moves only horizontally on its row.
&
4 - if set, shows drop icons in actual row under mouse instead of headers.
&
8 - if set, permits dropping columns to next empty part by dropping the first / last column in part on its edge.
&
16 - if set, permits dropping columns to next empty part by dropping any columns to the edge of the first / last column in part.
&
32 - if set, permits dropping columns to next empty part by dropping the column to the near unsuitable part (Toolbars / Scroll / Empty).
Various parameters for column dragging in tree.
&
1 - if set, drops columns as the last child instead of the first child.
&
2 - if set, expands column when dropped to its children.
&
4 - if set, expands column when dragging above its Collapse icon.
If in given
column is possible to drag cell to move the
row.
If in given
row is possible to drag cell to move the
column.
By default it is set in
Index and
Header columns / rows.
If set, the row / column cannot be moved, bit array:
&
1 - cannot be moved directly. If it is in
Block, the whole block cannot be moved, but the item still can be moved inside the block. It can be still moved when moving
Block by another row / column.
&
2 - cannot be moved inside its
Block. If it is not in block, the setting is ignored.
&
4 - it is not moved with any parent's children.
&
8 - cannot be moved outside its grid,
&
16 - cannot be moved outside its part (but can be moved to the same part in another grid).
If set, the row / column cannot be copied, bit array:
&
1 - cannot be copied directly. If it is in
Block, the whole block cannot be copied too.
&
2 -
unused.
&
4 - it is not copied with any parent's children,
&
8 - cannot be copied outside its grid,
&
16 - cannot be copied outside its part (but can be copied to the same part in another grid).
If other rows / columns can be placed next to this row / column, bit array:
&
1 - cannot insert before the row / column, except moving inside block
&
2 - cannot insert after the row / column (after its children if any), except moving inside block.
&
4 - cannot insert before the row / column when moving inside block
&
8 - cannot insert after the row / column (after its children if any) when moving inside block.
Reference to default item (its
id) for all added children that have not set their
D explicitly.
It must be of the same kind as the referrer (Row can refer only to DefRow, etc.).
If not set,
CD is used.
Reference to default item (its
id) for all children that have not set their
D explicitly.
It must be of the same kind as the referrer (Row can refer only to DefRow, etc.).
It is used for initialization of children without
D attribute and also for adding new children without
D attribute to this parent.
Comma separated list or array of strings.
The row / column accepts as children dropped items only if their
DragId is listed here.
Default value is "Row" for rows and "Col" for columns.
Row / column identification to accept dropping to parent row / column by
Accept attribute.
Default value is "Row" for rows and "Col" for columns.
Tool string
D
= "Add"
Default toolbar cell to show Add icon to add / copy rows / columns to grid. Displays popup menu to choose the action.
Tool string
D
= "AddRows"
Default toolbar cell to show AddRows icon to add one or more rows above actual focus position. Adds count of actually focused rows.
Tool string
D
= "AddCols"
Default toolbar cell to show AddCols icon to add one or more columns to the left of actual focus position. Adds count of actually focused columns.
Tool string
D
= "CopyRows"
Default toolbar cell to show CopyRows icon to add copy of one or more focused or selected rows above actual focus position.
Tool string
D
= "CopyCols"
Default toolbar cell to show CopyCols icon to add copy of one or more focused or selected columns to the left of actual focus position.
Tool string
D
= "AddRowEnd"
Default toolbar cell to show AddRowEnd icon to add one new row to the end of default row part.
Tool string
D
= "AddColEnd"
Default toolbar cell to show AddColEnd icon to add one new column to the end of default column part.
Actions
AddRow / AddCol
(int target = 0, int position = 0, bits action = 0, bits copytype = 63)
OnClickAddRow/Col, OnClickAddRows/Cols, OnClickAdd
Adds new row / column next to the actual or focused row / column or duplicates the row / column.
position - where the new row / column is placed:
0 - above,
1 - below,
2 - as the first child,
3 - as the last child,
string as the last row / column of the part.
action specifies action and various options, bit array:
1.,2.bit | &3 | = 0 - add, 1 - move, 2 - copy, 3 - copy with children (fails, if no copied row / column has child). |
3.bit | &4 | = 4 - ignores NoMove / NoDuplicate / Fix / Accept, moves or copies all given items regardless on the permission. |
4.bit | &8 | = 8 - without children, copies / moves only given items, without their child rows / columns |
5.bit | &16 | = 16 - without Block, copies / moves only given items, not all items with the same Block. |
6.bit | &32 | = 32 - only visible, but still copies / moves collapsed children if not set with 8. |
7.bit | &64 | = 64 - plain, all rows / columns copies to the same level, 0 - preserves levels if the rows / columns contain both children and parents. |
8.bit | &128 | = 128 - if set, does not expand parent row(s) of added children. |
copytype what is copied, default is all, bit array:
&
1 - values in
V and
U, &
2 - attributes in
A and
B, &
4 - editable formulas in
E,
&
8 - JavaScript formulas in
F, &
16 - row span in
RS, &
32 - column span in
CS.
Actions
AddRows / AddCols
(int target = 0, int position = 0, bits action = 0, bits copytype = 63, int min = 2)
OnClickAddRow/Col, OnClickAddRows/Cols, OnClickAdd
Adds count of selected or focused rows / columns next to the actual or focused row / column or copies here the selected or focused rows / columns.
min - minimal count of the selected / focused rows / columns for the action success. If set to
0 - it works as
AddRow /
AddCol if no rows / columns are selected.
Other parameters are the same as
AddRow /
AddCol.
Actions
Drag
(int target = 0, bits actions = 15, bits options = 0)
OnDragHeader, OnDragAny, OnCtrlDragHeader, OnCtrlDragAny
Starts moving or copying row(s) or column(s) by mouse dragging.
actions - bit array = &
1 - move row(s), &
2 - copy row(s), &
4 - move column(s) / toolbar cell, &
8 - copy column / toolbar cell.
If possible both copy and move, the move is preferred.
options specifies action and various options, bit array:
1.,2.bit | &3 | selected:
0 - only the dragged row / column.
1 - all selected, if the dragged row / column is selected, otherwise only dragged row / column.
2 - all selected, if the dragged row / column is selected, otherwise fails. |
3.bit | &4 | = 4 - ignores NoMove / NoDuplicate / Fix / Accept, moves or copies all given items regardless on the permission. |
4.bit | &8 | = 8 - without children, copies / moves only given items, without their child rows / columns |
5.bit | &16 | = 16 - without Block, copies / moves only given items, not all items with the same Block. |
6.bit | &32 | = 32 - only visible, but still copies / moves collapsed children if not set with 8. |
7.bit | &64 | = 64 - plain, all items copies to the same level, 0 - preserves levels if the items contain both children and parents. |
It can be assigned only to dragging events.
Grid method Row / Col / Row[] / Col[]
Add
(any src = null, any par = null, any next = null, int options = 0, bits copytype = 63)
Adds or moves (
options&
2 =
0) or copies (
options&
2 =
2) row(s) / column(s) inside / into grid.
It moves or copies also from another grid if the
src is row(s) / column(s) in another grid.
src specifies the row(s) / column(s) that are added / copied / moved.
src | name | description |
null / 0 | add one | adds one new empty Row / Col and returns it |
number > 0 | add more | adds the src count of new empty Rows / Cols and returns them in array |
object | add one and preset | adds one new empty Row / Col, fills it by attributes in src and returns it |
object [ ] | add more and preset | adds src.length new empty Rows / Cols, fills them by attributes in the src items and returns them in array.
If the item in the src is null, presets from previous item, if any. |
Row / Col | move / copy one | moves or copies the src and returns it or its copy. To return all moved or copied rows in case of added Block or children pass src in one item array instead. |
Row [ ] / Col [ ] | move / copy more | moves or copies all Rows / Cols in src and returns them or their copies in array.
If the item in the src is null, copies / moves the item after previous item, if any.
All items in src must be from the same grid and of the same kind (Row or Col or object).
If the item in the src is null, it gets next Row / Col of the previous item in the array.
|
par and
next specify position where to place the copied / moved rows / columns.
To add new Row with different column set than first pass src as { S:"the set id" }.
par | next | added / copied / moved rows / columns are placed |
null (add) | null / true | as the last / first rows in "Body" part (on level 0, first set) |
null (copy / move) | null / true | as the last / first items in the src part (without level change, on src set) |
Part id | null / true | as the last / first items in par part (on level 0, first set) |
Part id | Set id | as the last items in par part (on level 0, next set) |
Part id | Row / Col | before the next (on level 0, on next set) |
null | Row / Col | before the next (without level change or added on level 0, on next set) |
Row / Col | Row / Col | before the next (on par level + 1, on next set) |
Row / Col | null / true | as the last / first children of the par (on par level + 1, on par set) |
options specifies various options, bit array:
1.bit | &1 | = 1 - saves changes, sets rows / columns as Added or Moved. If moved from other grid sets Deleted to the source rows / columns instead of deleting them. |
2.bit | &2 | = 2 - copies existing rows, either from other grid, 0 - moves existing rows, either from other grid. |
3.bit | &4 | = 4 - ignores NoMove / NoDuplicate / Fix / Accept, moves or copies all given items regardless on the permissions. |
4.bit | &8 | = 8 - without children, copies / moves only given items, without their child rows / columns. |
5.bit | &16 | = 16 - without Block, copies / moves only given items, not all items with the same Block. |
6.bit | &32 | = 32 - only visible, but still copies / moves collapsed children if not set with 8. |
7.bit | &64 | = 64 - if added to deleted or hidden parent it does not change the deleting state and visibility, 0 - adds children to deleted / hidden parent always as deleted / hidden. |
8.bit | &128 | = 128 - does not change L if set. |
9.bit | &256 | = 256 - always returns array of added rows / columns instead of single row / column. |
copytype what is copied or moved from other grid, default is all, bit array:
&
1 - values in
V and
U, &
2 - attributes in
A and
B, &
4 - editable formulas in
E,
&
8 - JavaScript formulas in
F, &
16 - row span in
RS, &
32 - column span in
CS.
Returns added / moved / copied Row or Col (for
src = null, 0, object, Row, Col) or array of added / moved / copied Rows / Cols (for
src = number>0, object[], Row[], Col[]).
Or returns null if nothing was modified.
API event bool
OnTestAdd
(Grid grid, Row[] / Col[] / int items, Row / Col / string parent, Row / Col next, int action, bits copytype, bool cols, bool test)
Called before row(s) or columns(s) in
items are added / moved / copied by actions
Add....
items can be integer number as count of rows / columns to add for
action =
0.
action =
0 - add,
1 - move,
2 - copy.
parent is parent Row / Col where the
items will be added / moved / copied as children or it is Part id for root.
next is Row / Col before that are the
items added / moved / copied. It can be null for the end.
copytype what will be copied, bit array:
&
1 - values in
V and
U, &
2 - attributes in
A and
B, &
4 - editable formulas in
E,
&
8 - JavaScript formulas in
F, &
16 - row span in
RS, &
32 - column span in
CS.
cols is
1 if manipulating columns or
0 if manipulating rows.
test is
1 when only testing possibility of the action, e.g. to display the action in popup menu.
Return true to cancel the action.
API event any
OnAdd
(Grid grid, Row[] / Col[] items, Row / Col / string parent, Row / Col next, int action, bits copytype, bool cols)
Called before row(s) or column(s) in
items are added / moved / copied. Called from
Add method.
items is array of the items to add / move / copy. It is never empty. The items can come from other grid than
grid,
use
grid.
GetGrid(
items[0]) to get the source grid.
action =
0 - add,
1 - move,
2 - copy,
3 - data added by
AddData.
parent is parent Row / Col where the
items will be added / moved / copied as children or it is Part id for root.
next is Row / Col before that are the
items added / moved / copied. It can be null for the end.
copytype what will be copied, bit array:
&
1 - values in
V and
U, &
2 - attributes in
A and
B, &
4 - editable formulas in
E,
&
8 - JavaScript formulas in
F, &
16 - row span in
RS, &
32 - column span in
CS.
cols is
1 if manipulating columns or
0 if manipulating rows.
In the event handler is possible to do:
1) continue | Return null or false or 0 to continue. |
2) cancel | Return true or 1 to cancel the action. |
3) modify | Modify the items array and return null to continue with the changed array.
It is possible to delete items from the array, change order of the items, insert new items (existing rows / columns from the same part for move / copy or new objects for add)
or modify attributes of the items (only for add).
For example: FGrid.OnAdd = function(G,R,par,next,action,ctype){ if(action==0) { R[0].Color = "red"; R.push({Color:"Blue"}); } } |
4) add else | Call Add method with new parameters and return its result. Only if the Add result is null return true.
The Add method will not call the OnAdd again, but will call OnAdded.
For example: FGrid.OnAdd = function(G,R,par,next,action,ctype){ return G.Add({Color:"Blue"},par,next) || true; } |
API event void
OnAdded
(Grid grid, Row[] / Col[] items, Row / Col / string parent, Row / Col next, int action, bits copytype, Row[] / Col[] sources)
Called after the row(s) or column(s) in
items have been added / moved / deleted. Called from
Add method.
The
items contains existing rows that have been added / moved / copied.
action =
0 - added,
1 - moved,
2 - copied,
3 - data added by
AddData.
parent is parent Row / Col where the
items have been added / moved / copied as children or it is Part id for root.
next is Row / Col before that have been the
items added / moved / copied. It can be null for the end.
sources is array of the same length as
items containing source rows / column that were copied. It is null for moved rows inside grid.
API event bits
OnStartDrag
(Grid grid, Row / Col src, bits actions, bits options)
Called before the dragging of row or column
src started by action
Drag.
actions are permitted actions for drop, bit array: = &
1 - move, &
2 - copy.
options are options passed to the
Drag action.
Return null to continue or new
actions (
0 - cancel,
1 - move,
2 - copy,
3 - move or copy) to permit them for drop.
API event int
OnDragging
(Grid grid, Row / Col / Tool src, Row / Col / Tool to, int type, int action, bits options, Event event, HTMLEvent mouseevent)
Called during dragging row, column or toolbar cell. It is called for every mouse move.
grid is source grid containing the dragged
src row / column.
to is destination row / column / toolbar to drop the
src on. The destination grid can be read by
grid.
GetGrid(
to).
type is place where to drop:
0 - no drop,
1 above
to,
2 - as the first child of
to,
3 - below
to.
action is actual action for drop:
1 move,
2 copy.
options are options passed to the
Drag action.
event is actual FastGrid mouse event.
mouseevent is standard JavaScript MouseEvent. Use for dropping outside grid.
Return null to continue. Or return new
type -
0 (no drop),
1 (above),
2 (to children),
3 (below) to change the drop position.
Or return negative
type -
-1 (above),
-2 (to children),
-3 (below) to immediately drop to the position.
Or return
-4 to cancel dragging immediately.
API event int
OnDrop
(Grid grid, Row / Col src, Row / Col to, int type, int action, bits options, Event event, HTMLEvent mouseevent)
Called before the row or column is dropped to its destination or before the dragging is canceled.
Parameters are the same as
OnDragging.
Return null to continue. Or return new
action -
0 (cancel),
1 (move),
2 (copy) to change the drop action.
API event void
OnEndDrag
(Grid grid, Row / Col src, Row[] / Col[] / Tool items, int action)
Called after dragging the row / column
src ended, after the changes have been done, but before Paint.
items are newly added or moved rows / columns. It is null if the dragging was canceled. Or it is toolbar cell, if dragged toolbar cell.
action is action that was done,
0 canceled,
1 moved,
2 copied.
API event void
OnDropped
(Grid grid, Row / Col src, Row / Col to, int type, int action, bits options, Event event, HTMLEvent mouseevent)
Called after the row or column is dropped to its destination or after the dragging is canceled. It is called after
OnEndDrag.
Parameters are the same as
OnDragging.
Grid method bool
Fix
(Row / Col item, string body = null, string head = null)
Fixes rows above the
item row or fixes column left to
item column.
If the
item is in
body part, moves all previous rows / columns to the end of
head part.
If the
item is in
head part, moves the
item and all next items to the beginning of the
body part.
Default value of
body is "Body" / "Cols". Default value of
head is previous part to the
body.
Returns true for change.
It preserves children and blocks, it splits in front of the block and above / left to root row / column.
Actions
Fix
(int target = 0, string body = null, string cols = null)
OnClickFix
Fixes rows above and columns left to actual or focused cell.
body and
cols can be set to the main part with not fixed items. If not set "Body" and "Cols" is used.
If the
body or
cols is set to
0 or false, the fixing is not done in this direction.
Actions
DragCell
(int target = 0)
Starts dragging actual cell by mouse. Its results should be handled by API events
OnDragCell and
OnDropCell.
API event bool
OnDragCell
(Grid grid, Row row, Col col, Grid togrid, Row torow, Col tocol, HTMLEvent event, HTMLElement ghost, bool start)
Called during dragging cell by action
DragCell.
grid is source grid with
row,
col as the cell being dragged.
togrid is actual grid under mouse. It can be null, if the mouse is outside any grid.
torow,
tocol cell under mouse in
togrid. It can be null, if no cell is under mouse.
event is standard JavaScript MouseEvent. Use especially to get target when dragging outside grid.
ghost is cell ghost tag displayed during dragging and moved with mouse. It can be changed or hidden in this event, but not removed.
start is true when called once on start dragging.
Return true to end the dragging - in this case the
OnDropCell is not called.
API event void
OnDropCell
(Grid grid, Row row, Col col, Grid togrid, Row torow, Col tocol, HTMLEvent event)
Called on drop cell dragged by action
DragCell. Do here the action to handle the drop, otherwise nothing will happen.
Parameters are the same as in
OnDragCell.
After finish there is automatically called
Paint() for the
grid and for
togrid, if any.
Grid method void
DragCell
(HTMLEvent event, any row = null, any col = null, int[] ghostrect = null, string ghosthtml = null)
Starts dragging grid cell from grid outside. Call this method in
onmousedown /
ontouchstart to start dragging specified cell to the grid.
It calls API events
OnDragCell and
OnDropCell like action
DragCell.
event is standard JavaScript MouseEvent object.
row and
col are any values that are passed as the second and third parameters to
OnDragCell and
OnDropCell API events.
If set
ghostrect as [left,top,width,height], it will show ghost tag on this absolute position and will move it with mouse.
ghosthtml is filled to the ghost tag created by
ghostrect.
The dragging starts after the mouse moves by Cfg DragSize pixels in any direction. If the drag does not start (the button is released), the API events are not called.
Grid method void
DragRow
(HTMLEvent event, Row / object row = null, Col col = null, function notstarted = null)
Starts dragging the grid
row from grid outside. Call this method in
onmousedown /
ontouchstart to start dragging specified row to the grid.
The dragged row can be dropped to the grid or to another grid according to the standard dragging permissions.
During dragging there are called all API dragging events for dragging rows / column like for action
Drag.
The
row can be also object with some row attributes or null to add new temporary hidden row to the grid and drag it to the new place.
This added row must be shown or deleted in OnDrop or OnDropped API event!
The
col can be set to column that specifies the cell in row that is being caught by mouse.
Function
notstarted(
row,
col) is called when the dragging did not start, use it to modify the
row back if required. If the
row is object or null, it was not added in case the dragging did not start.
Grid method void
DragCol
(HTMLEvent event, Row row = null, Col / object col = null, function notstarted = null)
Starts dragging the grid
col from grid outside. Call this method in
onmousedown /
ontouchstart to start dragging specified row to the grid.
The dragged column can be dropped to the grid or to another grid according to the standard dragging permissions.
The
col can be also object with some column attributes or null to add new temporary hidden column to the grid and drag it to the new place.
This added column must be shown or deleted in OnDrop or OnDropped API event!
The
row can be set to row that specifies the cell in column that is being caught by mouse.
Function
notstarted(
row,
col) is called when the dragging did not start, use it to modify the
col back if required. If the
col is object or null, it was not added in case the dragging did not start.
Deleting
If deleting rows is permitted and if deleted rows are shown:
0 - rows cannot be deleted,
1 - rows can be deleted and deleted rows are hidden,
2 - rows can be deleted and deleted rows are shown and marked red.
The rows are removed instead of deleting, if RowChanges has not set 3.bit &4.
If deleting columns is permitted and if deleted columns are shown:
0 - columns cannot be deleted,
1 - columns can be deleted and deleted columns are hidden,
2 - columns can be deleted and deleted columns are shown and marked red.
The columns are removed instead of deleting, if ColChanges has not set 3.bit &4.
If shows confirmation message when deleting rows.
0 - no,
1 - yes,
2 - yes and colors the items to delete.
If set, the row / column cannot be deleted / undeleted or removed, bit array:
&
1 - cannot be deleted. If it is in
Block, the whole block cannot be deleted.
&
2 -
unused.
&
4 - it is not deleted with any parent's children.
Actions
DeleteRow / DeleteCol
(int target = 0, int del = null, bits options = 0)
OnClickDeleteRow/Col, OnClickDelete, OnDel
Deletes actual or focused row / column.
Parameters
del and
options are the same as in
Delete, except it always checks
ConfirmDelete
Actions
DeleteRows / DeleteCols
(int target = 0, int del = null, bits options = 0, int min = 0)
OnClickDeleteRows/Cols, OnClickDelete
Deletes selected or focused rows / columns.
min - minimal count of the selected / focused rows / columns for the action success.
If min = 0 and target = 5 it returns false if the action modifies the same rows / columns as action DeleteRow / DeleteCol.
Parameters
del and
options are the same as in
Delete, except it always checks
ConfirmDelete
Actions
UndeleteRows / UndeleteCols
(int target = 0, int type = 0, bits options = 0, int min = 0)
OnClickDeleteRows/Cols, OnClickDelete
Undeletes deleted rows / columns in grid according to the
type.
type =
0 - undeletes all deleted rows / columns in grid.
type =
1 - undeletes deleted rows / columns between selected / focused rows / columns.
type =
2 - undeletes deleted rows / columns next to and between selected / focused rows / columns.
type = &
4 - select the undeleted rows / columns and unselect previous selection.
min - minimal count of the selected / focused rows / columns for the action success.
If min = 0 and target = 5 and DeletingRows / DeletingCols = 2 returns false.
options - if it shows confirmation message =
0 - no,
1 - yes,
2 - yes and colors the items to delete,
3 - according to
ConfirmDelete.
Grid method Row / Col / Row[] / Col[]
Delete
(Row / Col / Row[] / Col[] src = null, int del = null, bits options = 0)
Marks row(s) / column(s) as deleted or undeleted or removes them permanently.
src specifies the row(s) / column(s) that are deleted / undeleted / removed.
It can be one Row or Col object or array of Row or Col objects - all the objects must be from the same grid and of the same kind (Row or Col).
del specifies the action:
null | undelete / delete | undelete if some of the items is deleted, otherwise delete. |
0 | undelete | the item(s) is not marked as deleted. |
1 | delete | the item(s) is marked as deleted. |
2 | remove | the item(s) is permanently removed and the change cannot be uploaded to server. |
options specifies various options, bit array:
1.,2.bit | &3 | - if it shows confirmation message = 0 - no, 1 - yes, 2 - yes and colors the items to delete, 3 - according to ConfirmDelete. |
3.bit | &4 | = 4 - ignores NoDelete, deletes all given items regardless on the permission. |
4.bit | &8 | = 8 - without children, deletes only given items, without their child rows / columns. |
5.bit | &16 | = 16 - without Block, deletes only given items, not all items with the same Block. |
6.bit | &32 | = 32 - only visible, but still deleted collapsed children if not set with 8. |
7.bit | &64 | = 64 - permits undeleting children of deleted parent. |
Returns deleted / undeleted / removed Row or Col (for
src = object) or array of deleted / undeleted / removed Rows / Cols (for
src = array).
Or returns null if no rows / columns were modified.
If the confirmation message is shown, the items are deleted asynchronously after function return and Paint is done.!
Grid method bool
IsDeleted
(Row / Col item)
Returns if the row / column is deleted.
API event bool
OnDelete
(Grid grid, Row[] / Col[] items, int del, bool test)
Called before row(s) or column(s) in
items are deleted / undeleted / removed. Called from
Delete method.
del =
0 - undelete,
1 - delete,
2 - remove.
test is true if just testing possibility of deleting, e.g. to display the action in popup menu.
Return true to cancel the action.
The event handler can modify the
items to delete / undelete / remove different row(s) / column(s).
API event bool
OnDeleting
(Grid grid, Row[] / Col[] items, int del)
Called directly before row(s) or column(s) in
items are deleted / undeleted / removed. Called after a user confirmed deleting. Called from
Delete method.
del =
0 - undelete,
1 - delete,
2 - remove.
Return true to cancel the action.
The event handler can modify the
items to delete / undelete / remove different row(s) / column(s).
API event void
OnDeleted
(Grid grid, Row[] / Col[] items, int del)
Called after row(s) or column(s) in
items are deleted / undeleted / removed, but before Paint. Called from
Delete method.
del =
0 - undelete,
1 - delete,
2 - remove.
Grid method bool
ShowDeleted
(bool show, bool cols = 0)
Sets
DeletingRows to 1 (
show = 0) or 2 (
show = 1) and hides / shows the rows accordingly.
For
cols = 1 modifies
DeletingCols instead.
Returns true if something changed.
Grid method void
ClearPart
(string part)
Clears all content (rows or columns) in given part. Low level function to clear all data. Does not mark changes. Does not call any API events.
Use it only to clear the largest parts like Body or Cols.
Showing and hiding
If hiding / showing rows is permitted.
If set to
2, the hidden rows are still shown, but colored, to permit showing hidden rows..
If hiding / showing columns is permitted
If set to
2, the hidden columns are still shown, but colored, to permit showing hidden rows.
If shows confirmation message when hiding rows.
0 - no,
1 - yes,
2 - yes and colors the items to hide.
If the row / column is hidden.
If set, the row / column cannot be hidden / shown, bit array:
&
1 - cannot be hidden / shown. If it is in
Block, the whole block cannot be hidden / shown.
&
2 - cannot be hidden / shown single in its
Block.
&
4 - it is not hidden / shown with any parent's children.
Cfg string[]
HiddenRows
Array or comma separated string of ids of rows that will be hidden on start.
If HiddenRows are defined more times in the input data, they are joined together, except if the first item is "-".
Cfg string[]
VisibleRows
Array or comma separated string of ids of rows that will be shown on start.
If VisibleRows are defined more times in the input data, they are joined together, except if the first item is "-".
Cfg string[]
HiddenCols
Array or comma separated string of ids of rows that will be hidden on start.
If HiddenCols are defined more times in the input data, they are joined together, except if the first item is "-".
Cfg string[]
VisibleCols
Array or comma separated string of ids of rows that will be shown on start.
If VisibleCols are defined more times in the input data, they are joined together, except if the first item is "-".
Actions
HideRow / HideCol
(int target = 0, bits options = 0)
OnClickHideRow/Col, OnClickHide
Hides actual or focused row / column.
Parameter
options is the same as in
Hide, except it always checks
ConfirmHide
Actions
HideRows / HideCols
(int target = 0, bits options = 0, int min = 0)
OnClickHideRows/Cols, OnClickHide
Hides selected or focused rows / columns.
min - minimal count of the selected / focused rows / columns for the action success.
If min = 0 and target = 5 it returns false if the action modifies the same rows / columns as action HideRow / HideCol.
Parameter
options is the same as in
Hide, except it always checks
ConfirmHide
Actions
ShowRows / ShowCols
(int target = 0, int type = 0, bits options = 0, int min = 0)
OnClickHideRows/Cols, OnClickHide
Shows hidden rows / columns in grid according to the
type.
type =
0 - shows all hidden rows / columns in grid.
type =
1 - shows hidden rows / columns between selected / focused rows / columns.
type =
2 - shows hidden rows / columns next to and between selected / focused rows / columns.
type = &
4 - select the shown rows / columns and unselect previous selection.
min - minimal count of the selected / focused rows / columns for the action success.
options - if it shows confirmation message =
0 - no,
1 - yes,
2 - yes and colors the items to delete,
3 - according to
ConfirmDelete.
Grid method Row / Col / Row[] / Col[]
Hide
(Row / Col / Row[] / Col[] src = null, int hide = null, bits options = 0, bits type = 0)
Shows / hides the row(s) / column(s).
src specifies the row(s) / column(s) that are shown / hidden. It can be one Row or Col object or array of Row or Col objects - all the objects must be from the same grid and of the same kind (Row or Col).
hide =
1 - hide,
0 - show,
null - change visibility (according to the first row / columns visibility state).
type specifies various options, bit array:
1.bit | &1 | = 1 - saves changes. |
2.,3.bit | &6 | = 0 - changes only manual visibility, 2 - changes only filtered visibility, 4 changes both manual and filtered visibility |
options specifies various options, bit array:
1.,2.bit | &3 | - if it shows confirmation message = 0 - no, 1 - yes, 2 - yes and colors the items to delete, 3 - according to ConfirmDelete. |
3.bit | &4 | = 4 - ignores NoHide, shows / hides all given items regardless on the permission. |
4.bit | &8 | = 8 - without children, shows / hides only given items, without their child rows / columns. |
5.bit | &16 | = 16 - without Block, shows / hides only given items, not all items with the same Block. |
6.bit | &32 | reserved |
7.bit | &64 | = 64 - permits showing children of hidden parent. |
Returns shown / hidden Row or Col (for
src = object) or array of shown / hidden Rows / Cols (for
src = array).
Or returns null if no rows / columns were modified.
If the confirmation message is shown, the items are deleted asynchronously after function return and Paint is done.!
Grid method bits
IsHidden
(Row / Col / Toolbar item)
Returns if the row / column / toolbar is hidden, bit array:
&
1 - row / column / toolbar is manually hidden by
Hidden attribute or by
Hide method.
&
2 - row / column is hidden by filter.
&
4 - row / column is hidden by collapsed parent.
&
8 - column is hidden by
HideGroupCols.
API event bool
OnHide
(Grid grid, Row[] / Col[] items, bool hide, bool test)
Called before row(s) or column(s) in
items are hidden / shown. Called from
Hide method.
hide =
0 - show,
1 - hide.
test is true if just testing possibility of showing / hiding, e.g. to display the action in popup menu.
Return true to cancel the action.
The event handler can modify the
items to hide / show different row(s) / column(s).
API event void
OnHid
(Grid grid, Row[] / Col[] items, bool hide)
Called after row(s) or column(s) in
items are shown / hidden, but before Paint. Called from
Hide method.
hide =
0 - show,
1 - hide.
Grid method bool
ShowHidden
(bool show, bool cols = 0)
Sets
HidingRows to 1 (
show = 0) or 2 (
show = 1) and hides / shows the rows accordingly.
For
cols = 1 modifies
HidingCols instead.
Returns true if something changed.
Layout menu
Dialog to choose visible (exported, printed) rows, columns, toolbars and scrollbars.
Default definition is in
Dialogs.js, in
Dialogs.Layout. Default setting in the Script can be changed like
Dialogs:{ Layout: { Script: { MaxCols:10 } } }
Menu item name in
Layouts menu for given row / column. If set to
-1, it is used as the row / column
id.
If more row or columns share the same
Item, they are controlled together by one item in the
Layout menu.
If not set or set to
0 the column/row is not displayed in this group.
Caption for the first group can be set in
Text as
$ItemCaptionN, where
N is "R" for rows, "C" for columns, "T" for toolbars or "S" for scrollbars. It can be set
*-1 to
*-8 to display specific separator only.
Item text can be set in
Text as
$ItemXXX, where
XXX is the
Item attribute value. If not set, the attribute value XXX is used as the text.
There are also available items for individual Layout menus
ItemHide,
ItemExport,
ItemPrint,
ItemCopy,
ItemPaste,
ItemSearch.
Menu item name in
Layouts menu for given row / column.
X can be number
1 -
5.
Every row / column can have up to six Item to be included in up to six groups in the
Layout menu.
The row / column is shown only if it is set "on" in all its menu Item.
Caption for the
X group can be set in
Text as
$ItemCaptionNX, where
N is "R" for rows, "C" for columns, "T" for toolbars or "S" for scrollbars. For example
Text:{$ItemCaptionC2:"Special columns"}
Item text can be set in
Text as
$ItemXXX, where
XXX is the
ItemX attribute value. If not set, the attribute value XXX is used as the text.
There are also available items for individual Layout menus
ItemHide{X},
ItemExport{X},
ItemPrint{X},
ItemCopy{X},
ItemPaste{X},
ItemSearch{X}.
Script int
MaxRows
[20]
Maximal displayed rows (including captions) in the menu. If items count exceeds this maximum, the items are split to appropriate count of columns.
Script int
MaxItem
[5]
Maximal index of
Item attribute, 5 means Item, Item1, Item2, Item3, Item4, Item5.
Script string[]
Sections
["CRTS"]
Array or comma separated string as tested sections and their order in the menu, "C" is columns, "R" is rows, "T" is toolbars, "S" is scrollbars.
Script int
Options
[0]
Options for
Hide method attribute
options, for columns and rows.
Script string
Attribute
["NoHide"]
Attribute tested in all the items. Only items with this attribute as zero are listed in the menu.
Script string
Caption
["$LayoutCaption"]
The menu caption text. Can be set to "" to not show the caption.
Script string[]
Buttons
[["Ok","Clear","Cancel"]]
List of buttons the menu shows. It can be set to
0 to not show the buttons.
Script object
Item
[{ Bool:1 }]
Predefined settings for every item. Can be set to
{ Bool:5 } to show all the checkboxes with three state (on, off, unknown).
Script object
Input
Values of the items on start. The format is object
{ T: {}, R: {}, C: {}, S: {} }, every subobject contains the items as X[id] = 1/0, 1 if chosen.
If the
Input is defined and the item is not listed in it, it has value
-1 as unknown state.
Script method object
GetInput
(Grid grid, object Input)
Callback function. If defined, calls the function to get new or modify the
Input dynamically.
Script method object
GetResults
(Grid grid, int chosen = 0)
Support function returns the results as checked / unchecked items.
Returns chosen items in object
{ T: {}, R: {}, C: {}, S: {} }, every subobject contains the items as X[id] = 1/0, 1 if chosen.
If set
chosen, returns only chosen items in object
{ T:[], R:[], C:[], S:[] } as arrays of chosen items. For
chosen =
2, returns also the not chosen items with "-" prefix.
Selecting rows and columns
Selected rows and columns are independent on
focused rows / columns / cells and are used by actions taking selected rows / columns.
Selected rows and columns are usually
not used in
sheet.
Default focus and select behavior is for
grid - focus single cell and independent row and column selection.
For
sheet focus and select behavior set
Cfg: { Focus:31, SelectRows:0, SelectCols:0 } - focus cell ranges and manipulate them.
If selecting rows is permitted.
If selecting columns is permitted.
Cfg string[]
SelectedRows
Array or comma separated string of ids of selected rows.
If SelectedRows are defined more times in the input data, they are joined together, except if the first item is "-".
Cfg string[]
SelectedCols
Array or comma separated string of ids of selected columns.
If SelectedCols are defined more times in the input data, they are joined together, except if the first item is "-".
If set to
1 in data, selects the row / column. If the row / column is already selected by
SelectedRows /
SelectedCols, does nothing.
If set to
0 in data, unselects the row / column. If the row / column is not selected by
SelectedRows /
SelectedCols, does nothing.
If set, the row / column cannot be selected / unselected, bit array:
&
1 - cannot be selected / unselected. If it is in
Block, the whole block cannot be selected / unselected.
&
2 - cannot be selected / unselected single in its
Block.
&
4 - it is not selected / unselected with any parent's children.
&
8 - it is not counted in selected rows / columns for
SelectAllType values 2+16 / 3+16.
Specifies behavior of icon
SelectRows /
SelectCols.
0 - Only icon Default (no suffix).
1 - Icon Off (_0) for no selected, icon On (_1) for all selected and icon Default (no suffix) for others.
2 - Icon Off (_0) for no selected, icon On (_1) for all selected and icon number 1-99 for others.
3 - Icon Off (_0) for no selected, icon red number for all selected and icon number 1-99 for others.
&4 - If all rows / columns are selected, the newly added rows / columns are selected too.
&8 - If all rows / columns count is reduced by
ClearSelected.
&16 - If set with value
2 /
3, it checks
NoSelect&
8 when showing count of selected rows / columns.
When the row or column selection is cleared and which rows are affected by select all.
1.bit &
1 If selection is cleared for deleted rows / columns. For
DeletingRows /
DeletingCols =
2 must be unset also 3. bit to not clear the selection.
2.bit &
2 If selection is cleared for filtered rows / columns.
3.bit &
4 If selection is cleared for manually hidden rows / columns.
4.bit &
8 If selection is cleared for collapsed child rows.
Actions
SelectRow / SelectCol
(int target = 0, int sel = null)
OnClickSelectRow/Col
Selects actual or focused row / column - always only one row / column.
sel =
1 - select,
0 - unselect,
null - change selection.
Actions
SelectRows / SelectCols
(int target = 0, int sel = null)
OnClickSelectRows/Cols
Selects (
sel =
1) or unselects (
sel =
0) all rows / columns in grid.
For
sel =
null unselects all selected rows / columns or selects all rows / columns.
Actions
DragSelectRows
(int target = 0, int sel = null)
OnDragSelectRow
Selects (
sel =
1) or unselects (
sel =
0) rows by mouse dragging.
For
sel =
null chooses according to the first row selection state.
It can be assigned only to dragging events.
Actions
DragSelectCols
(int target = 0, int sel = null)
OnDragSelectCol
Selects (
sel =
1) or unselects (
sel =
0) columns by mouse dragging.
For
sel =
null chooses according to the first column selection state.
It can be assigned only to dragging events.
Grid method Row / Col / Row[] / Col[]
Select
(Row / Col / Row[] / Col[] src = null, int sel = null)
Marks row(s) / column(s) as selected or removes the selection mark.
sel =
1 - select,
0 - unselect,
null - change selection (unselect if any row is selected, otherwise select).
src specifies the row(s) / column(s) that are selected / unselected.
It can be one Row or Col object or array of Row or Col objects - all the objects must be from the same grid and of the same kind (Row or Col).
It always changes selection only of given rows / column, not their children or others in Block.
Returns changed Row or Col (for
src = object) or array of changed Rows / Cols (for
src = array).
Or returns null if no rows / columns were modified.
Grid method Row[] / Col[]
GetSelected
(int type = 0, bool cols = 0, bool nohidden = 0)
Returns
selected (if permitted by
SelectingRows (
SelectingCols) =
1) or
focused rows (or columns if set
cols =
1).
For
type =
0 returns the rows (columns) in array by their ids.
The returned object must
not be modified. It is fast for SelectRows (SelectCols) = 1, because it returns internal object.
For
type =
1 returns the rows (columns) in standard array by index. It is slower, because it creates the array for both values of SelectRows (SelectCols).
For
type =
2 returns only count of the rows / columns.
For
type =
3 returns only count of the rows / columns that can be selected. Returns null if not set
SelectAllType.
For
nohidden includes only visible rows / columns in focused range.
Grid method bool
IsSelected
(Row / Col item)
Returns true if given row or column is
selected (if permitted by
SelectingRows (
SelectingCols) =
1) or it is in
focused range.
API event bool
OnSelect
(Grid grid, Row[] / Col[] items, int sel, bool test)
Called before row(s) or column(s) in
items are selected / unselected. Called from
Select method.
It is not called when selecting / unselecting all rows in grid.
sel =
0 - unselect,
1 - select,
2 - select added row for
SelectAllType&4,
null - forced unselect for
ClearSelected or when removing row / column.
test is true if just testing possibility of showing / hiding, e.g. to display the action in popup menu.
Return true to cancel the action.
The event handler can modify the
items to select / unselect different row(s) / column(s).
API event void
OnSelected
(Grid grid, Row[] / Col[] items, int sel)
Called after row(s) or column(s) in
items are selected / unselected, but before Paint. Called from
Method method.
It is not called when selecting / unselecting all rows in grid.
sel =
0 - unselect,
1 - select,
2 - select added row for
SelectAllType&4,
null - forced unselect for
ClearSelected or when removing row / column.
API event bool
OnSelectAll
(Grid grid, bool sel, bool test)
Called before all rows / columns in grid are selected (
sel =
1) or unselected (
sel =
0).
test is true if just testing possibility of deleting, e.g. to display the action in popup menu.
Return true to cancel the action.
API event bool
OnSelectedAll
(Grid grid, Row[id] / Col[id] newselected, Row[id] / Col[id] oldselected, bool sel, bool test)
Called after all rows / columns in grid were selected (
sel =
1) or unselected (
sel =
0).
newselected are newly selected rows / columns in grid as items by their id,
oldselected are originally selected rows / columns.
The event handler must
not modify the
newselected /
oldselected objects, but can select other rows by
Select method.
Return true to discard the selection changes and select the original rows / columns.
Fill cell values by dragging
Auto fill is done by dragging focus corner by assifned action
DragFocus.
The focus corner can be shown by setting
FocusActions bit
1 and
Focus must be set to 2 or 3.
Flags how the auto fill actions will fill the cells, bit array.
1. bit | &1 | If set, the source cell values will be copied in the filling direction. |
2. bit | &2 | If set, the filled numbers can be calculated as in numeric sequence. Only if there is constant increase/decrease. |
| | Only if filled in one direction. Only if the source area contains at least two cells in the filling direction. |
3. bit | &4 | If set and the fill area is smaller than source area, the rest of source area will be cleared. |
4. bit | &8 | If set, permits calculated filling also from one cell in the filling direction by step 1. |
5. bit | &16 | If set, permits calculated filling also string values ending by number, increasing that number. |
Comma separated list or array of cell attributes that are affected by mass changes like auto fill, copy, move, paste.
In sheet it is set to: "Format,NoEdit,Wrap,Align,VertAlign,Rotate,Color,Pattern,PatternColor,TextColor,TextLine,TextLineColor,TextStyle,TextSize,TextFont,TextShadow,TextShadowColor,RowBorder,ColBorder,Link,Tip".
Grid method object
FillRange
(object[] NewRange, object[] OldRange, bits type = AutoFillType, string[] attrs = EditAttrs )
Fills range
NewRange by values in
OldRange according to the
type (
AutoFillType). Called when dragging focus corner.
The ranges are set as [top_row,left_col,bottom_row,right_col].
API event bool
OnAutoFill
(Grid grid, any[][] Values, any[][][] Attrs, Row[] Rows, Col[] Cols, int orcnt, int occnt, int rcnt, int ccnt, bool rdir, bool cdir)
Called after cell range is ready to auto fill after dragging cell focus corner.
Values is two dimensional array as
Values[rowidx][colidx] of values to be set to cells in
Rows[rowidx],
Cols[colidx].
Values contain already calculated values. They can be changed in this event to fill different values.
Attrs is two dimensional array as
Attrs[rowidx][colidx] of arrays containing attribute values to be set to cells in
Rows[rowidx],
Cols[colidx].
The last array of the
Attrs contains: [Edit_Formula,Row_Span,Col_Span,
EditAttrs[0],EditAttrs[1],...] .
The direction of
Values/
Rows/
Cols is in the direction of filling - they can are reversed to position in grid if
rdir or
cdir is true.
orcnt /
ocnt is size of source area. Source area is always in beginning of
Values/
Rows/
Cols.
rnct /
ccnt is size of filling area including source area. If set
AutoFillType&2, it can be even smaller than source area.
rdir is vertical direction -
0 go down,
1 go up;
cdir is horizontal direction -
0 go right,
1 go left.
Return
true to cancel the action - no filling will be done.
API event bool
OnAutoFilled
(Grid grid, Row r1, Col c1, Row r2, Col c2, bool rdir, bool cdir, Row ro, Col co)
Called after cell range has been auto filled after dragging cell focus corner.
r1,
c1,
r2,
c2 is the selected cell range.
r1,
c1 is always the firstly clicked cell.
rdir is vertical direction -
0 when
r2 is under
r1 and
1 if
r2 is above
r1.
cdir is horizontal direction -
0 when
c2 is right from
c1 and
1 when
c2 is left from
c1.
r1,
c1,
ro,
co is the originally selected range, often only one cell.
Locking grid against changes
Comma separated string or array of actual locks set to grid. Case insensitive. Defining more
Lock attributes merges the locks. If the lock name starts by "-", it is removed from the locks. If the lock name is directly "-", it clears all the locks set before.
The lock name can be direct lock or group id from the
Locks. Available direct locks:
EditAll - preserves editing completely regardless on
NoEdit attribute, like
Editing =
-1. Affects also formula editing and link editing. All cells hide
List,
Date and
Filter icons and the
List (except
Popup toolbar button),
Date and
Filter dialogs cannot be shown.
Edit - preserves editing, like
Editing =
0. Affects also formula editing. Not editable cells hide
List,
Date and
Filter icons and the
List (except
Popup toolbar button),
Date and
Filter dialogs cannot be shown.
Write - sets inline editing in read only mode, like
Editing =
2. Affects also formula editing. The value cannot be changed, just selected and copied to clipboard. Permits
List /
Date /
Filter icons and the
List,
Date and
Filter dialogs can be shown, but cannot change the cell value or filter.
Formula - preserves editing cells with editable formula set, like
FormulaEditing =
0. Restricts entering editable formula to cell, the value starting by "=" is saved as string instead.
EditLink - preserves editing links, like
EditingLink =
0.
WriteLink - sets editing link in read only mode, like
EditingLink =
2. The link value cannot be changed, just selected and copied to clipboard.
Style - preserves changing cell style and format, like
EditingStyle =
0.
StyleAll - preserves changing cell style and format completely, regardless on
NoEditStyle, like
EditingStyle =
-1.
Controls - preserves eiditng in cells with
NoEdit <
0, used mostly on toolbars. Not editable cells hide
List and
Date icons and the
List (except
Popup toolbar button),
Date and
Filter dialogs cannot be shown.
NoEdit - restricts changing cell editing permissions by action
SetNoEdit.
Focus - restricts changing focus.
FocusEdit - restricts focusing not editable cells.
Hover - hide cursor on cells and images under mouse.
Cursor - show always "default" mouse cursor.
Tip - restricts showing tip for hovered cell.
EditTip - restricts adding / removing / changing comments for the cell.
Span - restricts spanning adjacent cells by users, both row span and column span.
Link - restricts following links (on
Link attribute and
<a> tags in cell html).
Toolbar - disables updating toolbars mode - restricts moving and hiding toolbar cells.
ResizeToobar - restricts resizing toolbars height.
ResizeTool - restricts resizing toolbar cells width.
Name - restricts defining and updating names for the cells / cell ranges.
AddRow,
AddCol - restricts adding new rows / columns or copying existing rows / columns.
DeleteRow,
DeleteCol - restricts deleting rows / columns.
MoveRow,
MoveCol - restricts moving rows / columns.
HideRow,
HideCol - restricts hiding and showing rows / columns.
ResizeRow,
ResizeCol - restricts resizing rows / columns.
ResizeRowPart,
ResizeColPart - restricts resizng row / column parts.
ResizeTag - restricts resizing main tag.
CollapseRow,
CollapseCol - restricts collapsing and expanding rows / columns.
IndentRow,
IndentCol - restricts indent / outdent rows / columns.
FixRow,
FixCol - restricts fixing rows / columns, moving them to and from left / top parts.
SelectRow,
SelectCol - restricts selecting rows / columns.
AddImage - restricts adding image files to grid by file open, file drop and copying existing images, like
AddingImages =
0.
DeleteImage - restricts deleting images from grid, like
DeletingImages =
0.
MoveImage - restricts moving images by dragging
DraggingImages =
0.
ChangeImage - restricts changing images - resizing, rotating, opacity, clip, hyperlink, zindex, like
ChangingImages =
0.
AddSheet - restricts adding new empty sheets.
DeleteSheet - restricts deleting existing sheets.
HideSheet - restricts hiding and showing sheets.
RenameSheet - restricts changing sheet id.
MoveSheet - restricts moving sheet tabs on toolbar.
SwitchSheet - restricts displaying another sheet from the book.
Import - restricts opening xlsx files in grid and dropping xlsx files to grid, like
ImportAction =
0
Export - restricts exporting grid data to xlsx file.
Save - restricts sending changes to server.
Reload - restricts reloading grid data from server.
Print - restricts printing grid to printer.
Pdf - restricts printing grid to pdf.
Filter - restricts changing actual filters.
Sort - restricts changing actual sorting.
Group - restricts changing actual grouping.
Search - restricts changing actual search.
Pivot - restricts changing actual or creating pivot. The pivot is locked if locked either in source or pivot grid.
Settings - restricts changing settings in configuration menu.
Cookie - restricts managing more configuration, including add / delete configuration.
AddCookie - restricts add new configuration to save.
DeleteCookie - restricts deleting existing configurations.
Copy - restricts copying to clipboard or to internal clipboard.
Paste - restricts pasting from clipboard or from internal clipboard.
Undo - restricts undo / redo.
Lock - cannot change the
Lock itself. It should
not be included in
Locks.
Defined group of locks that can be referred in
Lock and chosen by user on toolbar button
Lock menu. Both id and values are case insensitive.
The
Lock button menu text shown for the lock id is defined in
Texts as "$" + lowercase id, e.g.
$lockedit:"Lock editing".
Default value is
Locks: {
LockEdit:"Edit", LockFormula:"Formula", LockStyle:"Style", LockNoEdit:"NoEdit", LockControls:"Controls",
LockSpan:"Span", LockFocus:"Focus", LockSelect:"SelectRow,SelectCol", LockLinks:"Link", LockNames:"Name", LockTip:"EditTip",
LockEditLink:"EditLink", LockPaste:"Paste",
LockFix:"FixRow,FixCol", LockAdd:"AddRow,AddCol,DeleteRow,DeleteCol", LockResize:"ResizeRow,ResizeCol,ResizeRowPart,ResizeColPart,ResizeTag",
LockMove:"MoveRow,MoveCol,IndentRow,IndentCol", LockCollapse:"CollapseRow,CollapseCol", LockHide:"HideRow,HideCol",
LockAddImage:"AddImage,DeleteImage", LockImage:"MoveImage,ChangeImage",
LockSheets:"AddSheet,DeleteSheet,HideSheet,MoveSheet,RenameSheet", LockSwitchSheet:"SwitchSheet",
LockView:"Sort,Filter,Group", LockSettings:"Settings", LockSearch:"Search", LockPivot:"Pivot", LockCookies:"AddCookie,DeleteCookie,Cookie", LockToolbars:"Toolbar,ResizeToolbar,ResizeTool",
LockCopy:"Copy", LockPrint:"Print,Pdf", LockExport:"Export", LockImport:"Import", LockReload:"Reload", LockSave:"Save", LockUndo:"Undo", LockHover:"Hover,Cursor,Tip"
}.
Names of the locks and lock groups displayed in Locks menu. Defined in Text.js to be translated.
The Lock ids are here case insensitive.
Array or comma separated list of locks or lock groups displayed in Locks menu.
If set to "", the Locks menu displays all groups from
Locks.
Grid method bool
IsLocked
(string lock = null, bool all = 0)
Returns true if the grid is locked by given
lock.
lock can be comma separated string or array of direct locks or
Locks ids to check against
Lock.
For
all =
0 it returns true, if grid is locked by any item from
lock, for
all =
1 returns true only if all items in
lock are present in
Lock.
If
lock is null, it checks any or all ids from
Locks.
Grid method object
GetLock
(bool array = 0)
Returns actual
Lock. Only direct locks are listed.
All returned items are lowercase!
For
array =
0 returns internal object with locks by id like { lock1:1, lock2:1, ...}, this object must
not be changed.
For
array =
1 returns array of actual lock ids. Slower than
0.
Grid method void
SetLock
(string lock, int clear = 0)
Adds all items in
lock into grid
Lock.
lock can be comma separated string or array of direct locks or
Locks ids.
If
lock item starts by "-" or
clear =
1, it removes the item from
Lock instead of adding it.
If set
clear =
2 or
3 it first clears the
Lock, for
2 it removes only locks defined in
Locks.
Undo & redo
Permits undoing last actions and redoing the undone actions for specific features, available keywords:
* - Permits undoing all supported actions,
Value - changing cell value and editable formula,
Attr - changing any cell, row and column attribute value,
CfgAttr - changing any grid and part attribute (set in the
Cfg tag and part tag, undoes also changes done in configuration menus),
Span - spanning and splitting cells,
Focus - changing focused cells,
Row - the same as AddRow,HideRow,MoveRow,IndentRow,CollapseRow,SelectRow,Height,
AddRow - adding, copying, deleting and removing rows,
HideRow - showing and hiding rows,
MoveRow - moving rows,
IndentRow - changing row level in tree,
CollapseRow - expanding and collapsing rows in tree,
SelectRow - selecting rows,
Height - resizing rows,
Col - the same as AddCol,HideCol,MoveCol,IndentCol,CollapseCol,SelectCol,Width,
AddCol - adding, copying, deleting and removing columns,
HideCol - showing and hiding columns,
MoveCol - moving columns,
IndentCol - changing column level in tree,
CollapseCol - expanding and collapsing columns in tree,
SelectCol - selecting columns,
Width - resizing columns,
PartSize - resizing parts in both directions,
GridSize - resizing main tag in both directions,
Sort - sorting rows and columns,
Group - grouping rows and columns,
Filter - filtering rows and columns,
Search - searching in cells,
Name - changing
Names /
GlobalNames,
Image - changing
Images,
Lock - changing
Lock,
Cookie - loading another configuration, also reset, add and delete configuration,
Share - share configuration among all sheets with the same
UndoId,
Sheet - displaying another sheet,
AddSheet - add and delete sheet,
RenameSheet - change sheet id (move sheet and hide / show sheet is controlled by
CfgAttr).
Item starting by "-" is excluded, e.g. "*,-Col" sets all flags except the "Col..." flags and "Width".
If set and
Undo contains
Share, shares the undo queue among all grids with the same
UndoId, like in MS Excel sheets.
If set, undoes / redoes together all actions done within given time in milliseconds. For
UndoId it is set to 100 by default.
If set, the changes in the cell are not saved to undo chain and cannot be undone / redone. Affects Undo actions
Value and
Attr.
By default is 0 for cells and 1 for tools.
Actions
Undo
(int target = 0)
OnClickUndo
Undoes one action in undo chain. Fails if ther is no action to undo.
To undo all chained actions do
while(Grid.ActionUndo());.
Actions
Redo
(int target = 0)
OnClickRedo
Does again the last undone action in undo chain. Fails if ther is no action to redo.
To redo all chained actions do
while(Grid.ActionRedo());.
Grid method void
ClearUndo
(bool redo = 0)
Clears actual Undo / Redo chain, nothing can be undone / redone.
If set
redo, clears only the Redo chain, nothing can be redone.
Grid method void
MergeUndo
( )
Merges two last undo actions to be undone / redone together.
Grid method object
GetUndo
( )
Gets Undo as object of flags set to 1, all the flag names are lowercase. It does not return flags Row and Col.
For example it returns { value:1, attr:1, addrow:1, moverow:1 }.
Grid method void
SetUndo
(string[] undo )
Sets undo to Undo.