Cell
FastGrid documentation
Read and write any values by API
Grid method any
Get
(any row, any col, any attr = null, any def = null, object convert = null, bits direct = 0)
Reads one or more attributes from FastGrid object. Returns raw unformatted values (except if set
attr to number). For error returns
def.
Universal (takes objects or their ids) and safe (checks the input parameters) function but slower than the dedicated functions
GetValue,
GetNumber,
GetRange,
GetString,
GetAttr,
GetAttrs,
GetDefAttr,
GetCfgAttr,
GetPartAttr,
GetD,
GetSet.
JavaScript type of the returned value(s) is not specified and can be any suitable.
row can be object or string/number id of Row, Toolbar or Part or string default kind "Row", "Col", "Cell", "Toolbar", "Tool".
col can be object or string/number id of Col, Toolbar cell, Set or default item.
If
row is null, returns column attribute, if
col is null returns row attribute, otherwise returns cell attribute.
To use the Get with the ids, the rows, toolbars and parts should have unique ids among all others.
If
attr or its item is
null or empty or "Value" returns cell value or Value attribute.
If
attr or its item is "
Formula" return data formula, if
attr or its item is
E, returns editable formula.
If
attr is
not object, returns value of this attribute. For error it returns
def.
If
attr is
array as list of attribute names, returns array of values of these attributes. If
def is not null, for error it returns array filled by the
def values.
If
attr is
object as with attribute names = null, fills the values directly to the
attr and returns it. If
def is not null, for error it fills the array by the
def values.
If
attr or its item is a
number, returns formatted cell value as number, string or range according to the number
attr:
0: returns number or 0.
1: returns number or raw value.
2: returns number or string.
3: returns number as string or string.
4: returns number or
def.
5: returns rounded number by its
Format or string,
slower!
8: returns formatted string for display.
9: returns formatted string for edit.
16 -
31: returns value in array always. Value type as
attr&15 (0 - 9).
32 -
47: returns value in array only if the cell has set
Range otherwise fills one value. Value type as
attr&15 (0 - 9).
48 -
63: returns value in array only if the cell has set
Range and the value contains some separator otherwise fills one value. Value type as
attr&15 (0 - 9).
If returned number, Date strings are converted to number as count of milliseconds since 1/1/1970 or, if set
ExcelDates, to count of days since 1/1/1900.
convert - object with name = value pairs to convert the resulted value from name to value.
If the result is not included in
convert, it is returned unchanged.
For example if
convert is {red:"#F00",blue:"#00F",green:"#0F0"}, returns "#00F" for result "blue", etc.
direct - what source will be ignored, bit array:
Grid method int
Set
(any row, any col, any attr, any value, int changes = 0)
Writes one or more attributes to FastGrid object. Writes raw unformatted values.
Universal (takes objects or their ids) and safe (checks the input parameters) function but slower than the dedicated functions
SetValue,
SetString,
SetAttr,
SetDefAttr,
SetCfgAttr,
SetPartAttr,
SetD,
SetSet.
row can be object or string/number id of Row, Toolbar or Part or string default kind "Row", "Col", "Cell", "Toolbar", "Tool".
col can be object or string/number id of Col, Toolbar cell, Set or default item.
If
row is null, sets column attribute, if
col is null sets row attribute, otherwise sets cell attribute.
To use the Set with the ids, the rows, toolbars and parts should have unique ids among all others.
If
attr is its item is
null or empty or "Value" sets cell value or Value attribute.
If
attr or its item is "
Formula" sets data formula, if
attr or its item is
E, sets editable formula.
If
attr is
not object, sets value of this attribute.
If
attr is
array as list of attribute names, sets values of all these attributes.
The
value can be array with the same values as
attr with the values or one value (number/string/bool/null) to set the value to all the attributes. Returns count of changed attributes.
If
attr is
object as with attribute names = value, it ignores the
value and sets the values from the
attr and returns count of changed attributes.
If
attr or its item is a
number (including 0) and sets cell value,
converts the
value to date or number according to cell Type and EditFormat.
For Auto type it can change Format between "d" / "t" / "h" / "".
Returns true if the attribute value was changed, false if the
value is the same as the attribute value (no change was done) and null for error.
If
value is null, clears the attribute value to its default value (except
changes =
2).
changes controls how the cell is marked as changed:
0 -
simple set - fast, does not mark or clear changes, does not store or change original value, does not test if the value is the same.
1 -
set and mark - marks changes, stores original value before the first change, tests if the value is the same.
If the
value is the same as original value, clears the marked changes.
2 -
set, mark and restore - like
2, but if
value is the same as default value sets null to use the default value and
if
value is
null restores original value and clears the marked changes.
3 -
set and clear - clears marked changes and clears original value, the new cell value is taken as original unchanged value. Returns false if the value is the same as actual value and no original value is stored.
4 -
set and test - like
0 but tests if the value is the same.
changes=
1/
2/
3 is forced to
4 if not set
second bit of
CellChanges (cell) /
ToolChanges (tool)
or 7th bit of
RowChanges (row) /
ColChanges (column).
changes is forced to
4 when setting grid, part or default item attribute or "S" attribute.
Cell value
The cell value is read in this order:
OnGetValue(Row,Col), OnGetFormula(Row,Col,1), Row.E[Col.id], OnGetFormula(Row,Col,0), Row.F[Col.id], {Row, Row.D, Col, Col.D}.Formula,
{Row, Row.D, Col, Col.D}.V[Col.VIndex], {Row, Row.D, Col, Col.D}.U[col.UIndex], Row.Index, Col.Index, Grid.DefaultValue,
{Row, Row.D, Col, Col.D}.A.ValueFormula, {Row, Row.D, Col, Col.D}.{A.D / B / DA}.ValueFormula,
{Row, Row.D, Col, Col.D}.A.Value, {Row, Row.D, Col, Col.D}.{A.D / B / DA}.Value,
{Row, Row.D, Col, Col.D}.Mirror, {Row, Row.D, Col, Col.D}.Value.
If the column has set Important atribute, the order is:
OnGetValue(Row,Col), OnGetFormula(Row,Col,1), Row.E[Col.id], OnGetFormula(Row,Col,0), Row.F[Col.id], {Col, Col.D, Row, Row.D}.Formula,
{Row, Row.D, Col, Col.D}.V[Col.VIndex], {Row, Row.D, Col, Col.D}.U[col.UIndex], Row.Index, Col.Index, Grid.DefaultValue,
{Row, Row.D, Col, Col.D}.A.ValueFormula, {{Row, Row.D, Col, Col.D}.{A.D / B } / {Col, Col.D, Row, Row.D}.DA}.ValueFormula,
{Row, Row.D, Col, Col.D}.A.Value, {{Row, Row.D, Col, Col.D}.{A.D / B} / {Col, Col.D, Row, Row.D}.DA}.Value,
{Row, Row.D, Col, Col.D}.Mirror, {Col, Col.D, Row, Row.D}.Value.
The tool value is read in this order:
OnGetValue(Toolbar,Tool), OnGetFormula(Toolbar, Tool,0), {Tool, Tool.D, Toolbar, Toolbar.D}.Formula,
Tool.Value, Tool.D.Value, Tool.Mirror, Toolbar.Value, Toolbar.D.Value.
Defines cell values in the row. Preferred to
U if defined both.
It can be defined in three ways, every row can use its own way:
1)
Object - slower and longer, but simple definition, useful for fixed rows or smaller grids where speed of loading is not so critical.
Assigns values directly to column ids, no indexes are needed.
Example:
{ id:1, V: { A:1, B:3.5, C:-34, D:"abc", F:4, G:"", H:"\"\\\"", I:12 } }
2)
Array - it is fast and short if the most of values are numbers.
The values are assigned to cells according to
VIndex (first item to VIndex=0, second item to VIndex=1, ...).
Example:
{ id:1, V: [ 1, 3.5, -34, "abc", null, 4, "", "\"\\\"", 12 ] }.
3)
String as first character separated array - it is fast if the most of values are strings.
null value (if cannot be used empty string) is defined as "\x01". Separator can be chosen freely, but no value can contain the separator.
The values are assigned to cells according to
VIndex (first item to VIndex=0, second item to VIndex=1, ...).
Example:
{ id:1, V: "|1|3.5|-34|abc|\x01|4||\"\\\"|12" }
If the V contains value "
\x01", it is taken as null, but ignores the cell value in
U, if any.
If defined in default row, the values are copied to the rows' V attributes on loading (only where the row V item has null value), so later changes in default row do not change the cell values.
If defined in default row, its defined values override the row
U values except if set
Cfg IgnoreDVOnU =
1.
! Col any
V
In rare cases cell values can be defined also in columns or default columns.
These values are copied to the rows' V attributes on loading (only where the row V item has null value), so later changes of columns do not change the cell values.
The column
V can be defined as
Object,
Array or
String like the row
V, but it assigns values always by row ids, so for
Array and
String definition the row ids should be sequence numbers starting from 0.
Col int
VIndex
Column index to read cell values from Row
V and DefRow
V, when used
Array or
String definition.
If set to
-1, generates the value automatically, but only if not defined
UCode.
If set to
-2, generates the value automatically even if defined
UCode.
If set to
-3, never generates the value and always sets the VIndex to column id.
If not set (by default) generates the value automatically after all negative indexes were processed.
All columns without VIndex set positive or generated will get VIndex = column id, so their values cannot be set in data in
V in
Array or
String.
If more columns have the same VIndex, they share the same value in rows'
V, change in any of the columns will mirror the change to the other(s).
The automatically defined values are generated according to the order in data, generated are only not yet used indexes from 0.
Copied from default column on loading.
Default cell value, used if the cell has not set its value in
V or
U array.
Default value is set in Col.D.Value as empty string in Defaults.js.
Cell value can be set also in A, in attribute named Value.
Default value for all cells in rows. It is read before
Value from DefCell, Row and Col.
It can be used especially to speed up huge summary calculations for cells mainly without set value in
V /
U.
If set, the cell values cannot be mirrored by Mirror&1!
Toolbar cell value.
The toolbar cell value is read in this order:
Tool.Formula, Tool.D.Formula, Toolbar.Formula, Toolbar.D.Formula,
Tool.Value, Tool.D.Value, Toolbar.Value, Toolbar.D.Value.
Default value for all cells in the Toolbar.
Value used if the cell value is empty string or null. It is formatted according to the cell
Type and
Format. It is used for display and edit.
What to do if edited value is the same as
EmptyValue,
0 - stores empty string,
1 - stores the
EmptyValue.
String displayed if the cell value and
EmptyValue is empty string or null.
It is displayed as is. It is not used for editing.
It cannot contain HTML code.
If set, the
EmptyString can contain HTML code.
Using many cells with HTML code remarkably slows down paint!
If set, it is displayed in cell instead of cell value as is, as String type. It is
not used for editing.
It can contain HTML code.
Using incorrect HTML code can break down the grid completely!
The HTML code is controlled in the same way as
Html Type.
Using many cells with HTML code remarkably slows down paint!
Maximal length of all string values to display in cells. The limit includes HTML tags. If text with HTML code reaches the limit, all the HTML code is removed from the text.
Displaying very long strings in grid can remarkably slow down paint, especially with HTML code.
If set to
1, sets all null values in every row from their previous row in the same row set.
If set to
2, sets all null values in every row from the nearest previous row with longer array of
U or
V than the source row. It can be much faster than
1 in reading values, but the null values inside
U /
V arrays are not read from previous row.
If set, the cells in the part will ignores Value set in row, A, B and will also ignore cell Mirror.
When loading row pages individually on background, the first row in page is
not mirrored from row on previous page.
Use it to reduce input data and save memory when input data are sorted and prepared for grouping, so many cell values are the same as the previous row cell values.
Col bool
NoMirrorValues
[0/1] GetAttr
If set, ignores
MirrorValues for cells in this column - the cell in this column never read their values from previous row.
By default it is set to
1 in all special columns and
0 in all data columns.
Grid method any
GetValue
(Row row, Col col, bits direct = FV)
It is faster but less universal and safe than Get.
Returns raw cell value, without any conversion. JavaScript type of the returned value is not specified and can be any suitable.
Default cell value defined in default column "Base" is empty string, so empty string is returned for null or undefined cell value.
direct - what will be ignored, bit array:
1. bit &
1 - ignores JavaScript formula in
F /
Formula.
2. bit &
2 - ignores editable formula in
E.
3. bit &
4 - ignores
OnGetValue API event.
4. bit &
8 - ignores attribute
Value and
Mirror.
7. bit &
64 - ignores
SpannedValue in hidden spanned cell.
row, col can be also Toolbar cell.
? Grid method any
OnGetValue
(Grid grid, Row row, Col col, any value, int direct)
Called to get raw value of any cell, including Toolbar cells.
It is called from
GetValue with the same
row,
col and
direct parameters.
value is actual cell value to be returned. Return
value or new value.
Returning
null is the same as returning
value. To return null value return global constant
FGrid.Null.
Low level API event called many times.
Grid method any
GetValueSimple
(Row row, Col col)
Returns raw cell value only from
V and
U.
Ignores all other value settings like formulas, default value, Value in attribute, OnGetValue.
It is the fastest but special reading of cell value.
Grid method any
GetNumber
(Row row, Col col, int ret = 0, any def = null, any val = null)
It is faster but less universal and safe than Get.
Returns cell value as number. Date strings are converted to number as count of milliseconds since 1/1/1970 or, if set
ExcelDates, to count of days since 1/1/1900.
Other values that cannot be converted to number are returned according to the
ret:
ret =
0: returns number or 0.
ret =
1: returns number or raw value (also with HTML code).
ret =
2: returns number or string (without HTML code).
ret =
3: returns number as string or string (without HTML code).
ret =
4: returns number or
def.
ret =
5: returns rounded number by its
Format or string (without HTML code),
slower!
If set
val, uses it for conversion instead of raw cell value returned by
GetValue.
row, col can be also Toolbar cell.
Grid method any
OnGetNumber
(Grid grid, Row row, Col col, any value, any rawvalue, int ret, any def)
Called to convert cell value to number. Called also for Toolbar cells.
It is called from
GetNumber with the same
row,
col,
ret and
def parameters.
rawvalue is the original raw cell value before conversion.
value is the converted cell value to be returned. Return
value or new value.
Returning
null is the same as returning
value. To return null value return global constant
FGrid.Null.
It is called after
OnGetValue. It is called also after
OnGetRange when converting to range of numbers.
Low level API event called many times, especially during calculations.
Grid method any
GetRange
(Row row, Col col, int ret = 0, int def = 0, int val = null)
It is faster but less universal and safe than Get.
Returns value of
Range cell as array of values as [from1,to1,from2,to2,from3,...].
For example for ""~4;7;12~15;20~"" returns [0,4,7,null,12,15,20,0].
ret =
0: fills number or 0.
ret =
1 /
2: fills number or string.
ret =
3: fills number as string or string.
ret =
4: fills number or
def.
ret =
5: fills rounded number by its
Format or string,
slower!
ret =
8 -
15: fills formatted string by
GetString with
src parameter as
ret&7.
For
ret < 16 returns always array, for empty / null values returns empty array.
For
ret >= 16 returns array only if the value contains separator, otherwise returns one value according to
ret&15.
If set
val, uses it for conversion instead of raw cell value returned by
GetValue.
row, col can be also Toolbar cell.
Grid method any
OnGetRange
(Grid grid, Row row, Col col, any value, any rawvalue, int ret, any def)
Called to convert cell value to range of values. Called also for Toolbar cells.
It is called from
GetRange with the same
row,
col,
ret and
def parameters.
rawvalue is the original raw cell value before conversion.
value is the converted cell value to be returned. Return
value or new value.
Returning
null is the same as returning
value. To return null value global constant
FGrid.Null.
It is called after
OnGetValue. It is called before
OnGetNumber and
OnGetString when converting to range of numbers or strings.
Low level API event can be called many times especially during paint.
Grid method any
GetNumbers
(Row row1, Col col1, Row row2, Col col2, int ret = 0, int def = 0, int direct = 0)
Returns array of values in given cell range. Returns one dimensional array, iterates the range horizontally first.
row1,
col1 and
row2,
col2 are opposite corners of the cell range.
Converts the values according to the
ret:
ret=
0 -
5: fills the values converted number by
GetNumber with given
ret value.
ret=
6: fills the raw values by
GetValue.
ret=
7: fills the raw values as string by
GetValue.
ret=
8 -
15: fills the values formatted to string by
GetString with
src parameter set to
ret&7.
ret=
16 -
31: fills the values as arrays using
GetRange with parameter
ret&15. Fills always arrays.
ret=
32 -
47: fills the values as arrays using
GetRange only if the cell has set
Range otherwise fills one value by
GetNumber /
GetString according to the
ret&15.
ret=
48 -
63: fills the values as arrays using
GetRange only if the cell has set
Range and the value contains some separator otherwise fills one value by
GetNumber /
GetString according to the
ret&15.
direct controls if returns calculated or source value or spanned cell value, see
GetValue.
Grid method string
GetString
(Row row, Col col, int src = 0, object Out = null, any val = null)
It is faster but less universal and safe than Get.
Returns cell value as formatted string according to cell attribute Type, Format / EditFormat, etc.
It also translates the text according to actual language.
src =
0 for display,
1 for edit.
If set
Out fills its attributes
Align and
Type chosen according to the value and format.
If set
val, uses it for conversion instead of raw cell value returned by
GetValue.
row, col can be also Toolbar cell.
Grid method string
OnGetString
(Grid grid, Row row, Col col, string value, any rawvalue, int src, object Out)
Called to convert range cell value to range of values. Called also for Toolbar cells.
It is called from
GetString with the same
row,
col,
src and
Out parameters.
rawvalue is the original raw cell value before conversion.
value is the converted cell value to be returned. Return
value or new value.
Returning
null is the same as returning
value. To return null value return global constant
FGrid.Null.
It is called after
OnGetValue. It is called also after
OnGetRange when converting to range of strings.
Low level API event called many times.
Grid method bool
SetValue
(Row row, Col col, any value, int changes = 0, bool compare = 0, bits fast = 0)
It is faster but less universal and safe than Set.
Sets
value to the cell value, directly without any conversion.
Returns true if the value was changed, false if the
value is the same as the cell value (no change was done) and null for error.
changes controls how the cell is marked as changed:
0 -
simple set - fast, does not mark or clear changes, does not store or change original value, does not test if the value is the same.
1 -
set and mark - marks changes, stores original value before the first change, tests if the value is the same.
If the
value is the same as original value, clears the marked changes.
2 -
set, mark and restore - like
2, but if
value is the same as default value sets null to use the default value and
if
value is
null restores original value and clears the marked changes.
3 -
set and clear - clears marked changes and clears original value, the new cell value is taken as original unchanged value. Returns false if the value is the same as actual value and no original value is stored.
4 -
set and test - like
0 but tests if the value is the same.
changes=
1/
2/
3 is forced to
4 if not set first bit of
CellChanges /
ToolChanges.
Boolean value true is always stored as 1 and false as 0.
By default for changes compares values as 0 != "" != NaN != false and 1 != true, but if set
compare it takes 0 == "" == NaN == false a 1 == true.
The change is saved to Undo queue if
Undo contains "
Value" and
changes is set.
If set
fast, it avoids some actions to speed up: &
1 - does not recalculate grid, &
2 - does not repaint the part,
&
4 - does not test
NoChanges attribute, &
8 - does not test
Value attribute for comparing changes.
row, col can be also Toolbar cell.
Grid method any
OnSetValue
(Grid grid, Row row, Col col, any value, int changes)
Called before changing raw value of any cell, including Toolbar cells.
It is called from
SetValue with the same
row,
col and
changes parameters.
value is value to be set to the cell value. Return
value or new value to change it.
Returning
null is the same as returning
value. To return null value return global constant
FGrid.Null.
To cancel setting the value return global constant
FGrid.Cancel.
Low level API event.
Grid method void
OnAfterSetValue
(Grid grid, Row row, Col col, any value, any oldvalue, int changes)
Called after changed raw value of any cell, including Toolbar cells.
It is called from
SetValue with the same
row,
col and
changes parameters.
value is actual cell value that has been set.
oldvalue is original cell value that has been changed.
It is called only if the value was really changed, so it is
not called after every
OnSetValue call.
Low level API event.
Grid method bool
SetString
(Row row, Col col, string value, int changes = 0)
It is faster but less universal and safe than Set.
Sets cell value to given string
value.
Can convert the
value to date or number according to cell Type and EditFormat.
For Auto type it can change Format between "d" / "t" / "h" / "".
Returns true if the value was changed, false if the
value is the same as the cell value (no change was done) and null for error.
changes are the same as in
SetValue.
row, col can be also Toolbar cell.
Grid method any
OnSetString
(Grid grid, Row row, Col col, any value, string stringvalue, int changes, int src)
Called before setting string value to any cell, including Toolbar cells.
It is called from
SetString with the same
row,
col,
changes and
src parameters.
stringvalue is original string value before conversion.
value is converted value to be set to the cell. Return
value or new value to change it.
Returning
null is the same as returning
value. To return null value return global constant
FGrid.Null.
To cancel setting the value return global constant
FGrid.Cancel.
It is called before
OnSetValue.
Actions
ClearValue
(int target = 0)
Clears value in the actual cell or in all focused cells.
Actions
SetCase
(int target = 0, bool lower = 0)
OnClickUpperCase, OnClickLowerCase
Changes text to upper case (for
lower = 1 to lower case) on the actual cell or on all focused cells.
Cell attributes
The cell attribute value is read in this order:
OnGetAttr(Row,Col),
{Row, Row.D, Col, Col.D}.A[Col.AIndex][attribute+"Formula"],
{Row, Row.D, Col, Col.D}.{A.D / B / DA}[Col.AIndex][attribute+"Formula"],
{Row, Row.D, Col, Col.D}.A[Col.AIndex][attribute],
{Row, Row.D, Col, Col.D}.{A.D / B / DA}[Col.AIndex][attribute],
{Row, Row.D, Col, Col.D}.A[Col.AIndex].Mirror,
{Row, Row.D, Col, Col.D}[attribute].
If the column has set Important attribute, the order is:
OnGetAttr(Row,Col),
{Row, Row.D, Col, Col.D}.A[Col.AIndex][attribute+"Formula"],
{{Row, Row.D, Col, Col.D}.{A.D / B} / {Col, Col.D, Row, Row.D}.DA}[Col.AIndex][attribute+"Formula"],
{Row, Row.D, Col, Col.D}.A[Col.AIndex][attribute],
{{Row, Row.D, Col, Col.D}.{A.D / B} / {Col, Col.D, Row, Row.D}.DA}[Col.AIndex][attribute],
{Row, Row.D, Col, Col.D}.A[Col.AIndex].Mirror, {Col, Col.D, Row, Row.D}[attribute].
The tool attribute value is read in this order:
OnGetAttr(Toolbar,Tool), {Tool, Tool.D}.Formula,
Tool.Value, Tool.D.Value, Tool.Mirror, Toolbar.Value, Toolbar.D.Value.
Defines cell attributes in the row. Preferred to
B if defined both.
It can be defined in three ways, every row can use its own way:
1)
Object - slower and longer, but simple definition, useful for fixed rows or smaller grids where speed of loading is not so critical.
Assigns values directly to column ids, no indexes are needed.
Example:
{ id:1, A: { A:1, B:{Align:1}, C:{Format:"d",Align:2}, D:1, F:2 } }
2)
Array - it is faster and shorter if the most of the cells have set some attribute.
The values are assigned to cells according to
AIndex (first item to AIndex=0, second item to AIndex=1, ...).
Example:
{ id:1, A: [ 1, {Align:1}, {Format:"d",Align:2}, 1, null, 2 ] }.
3)
String as first character separated array - it is fast if the most of cells have some attribute in default cell and the defaults names are strings.
Separator can be chosen freely, but no value can contain the separator.
It can set only references to DefCells, not the direct attributes!
The values are assigned to cells according to
AIndex (first item to AIndex=0, second item to AIndex=1, ...).
Example:
{ id:1, A: ",1,D1,D2,1,,2" }.
The individual item can be a)
object with the attributes or b)
string or
number as reference to the
DefCells.
If the individual item is
object with attribute
D, the
D value is taken as reference to
DefCells, reads default attribute values from there and is used instead of
B, if any.
If the attribute value is "
\x01", it is taken as null, but ignores the attribute value in
B /
A.D, if any.
If defined in default row, the values are copied to the rows' A attributes on loading (only where the row A item has null value), so later changes in default row do not change the cell attributes.
If defined in default row, its defined values override the row
B values except if set
Cfg IgnoreDAOnB =
1.
! Col any
A
In rare cases cell attributes can be defined also in columns or default columns.
These attributes are copied to the rows' A attributes on loading (only where the row A item has null value), so later changes of columns do not change the cell attributes.
The column
A can be defined as
Object,
Array or
String like the row
A, but it assigns values always by row ids, so for
Array and
String definition the row ids should be sequence numbers starting from 0.
Col int
AIndex
Column index to read cell attributes from Row
A and DefRow
A, when used
Array or
String definition.
If set to
-1, generates the value automatically, but only if not defined
BCode.
If set to
-2, generates the value automatically even if defined
BCode.
If set to
-3, never generates the value and always sets the AIndex to column id.
If not set (by default) generates the value automatically after all negative indexes were processed.
All columns without AIndex set positive or generated will get AIndex = column id, so their values cannot be set in data in
A in
Array or
String.
If more columns have the same AIndex, they share the same attributes in rows'
A, change in any of the columns will mirror the change to the other(s).
The automatically defined values are generated according to the order in data, generated are only not yet used indexes from 0.
Copied from default column on loading.
Row, Col int
Important
[0/1]
If set in column higher than in row, it changes order of reading attribute values, prefers the column attribute before the row attribute.
By default it is set to
1 in all special columns like Header, Index, Panel and Filter and in rows Header and Index and
0 in all normal columns.
If set in column higher than in row, the column cells ignore their row attributes that are set in the column or its default column!
Row / column attribute value, used for all cells except if the cell has the attribute set in
A or
B array.
The attributes are set directly in row and column or in their default by the attribute name, e.g.
{id:1,Format:"d",Align:1,...}.
Toolbar cell attribute value.
Toolbar cell attributes are set directly in the Toolbar cell by the attribute name, e.g.
{id:1,Cells:[{id:"Cell1",Format:"d",Align:1},...],...}
The toolbar cell attribute value is read in this order:
Tool[attribute+"Formula"],
Tool[attribute], Tool.D[attribute], Toolbar[attribute], Toolbar.D[attribute].
Attribute value for all cells in the Toolbar except if the cell has set the attribute directly.
It can be set only directly to the cell, in object in A or in toolbar cell object.
If set, it reads all the cell attributes and value from cell set by
MirrorRow,
MirrorCol.
1. bit &1 |
Reads the cell value from mirror cell.
Only if the source cell has not set the value in
V, U, A Value, B Value, Cfg DefaultValue.
In toolbar cell only if the cell has not set Value attribute directly or its default cell.
|
2. bit &2 |
Reads any cell attribute from mirror cell.
Only if the source cell has not set the attribute in A or B.
In toolbar cell only if the cell has not set the attribute directly or in its default cell.
Not applied for reading the Mirror, MirrorRow, MirrorCol attributes.
|
3. bit &4 |
Writes the cell value to mirror cell instead of this cell.
This cell should not have set value, otherwise the changes is not visible by 1. bit.
|
4. bit &8 |
Writes all the cell attributes to mirror cell instead of this cell.
This cell should not have set the attribute value, otherwise the changes is not visible by 2. bit.
Not applied for writing the Mirror, MirrorRow, MirrorCol attributes.
|
Mirror has less priority than Index, to use Mirror in Header it is required to turn off the Index.
It can be set only directly to the cell, in object in A or in toolbar cell object.
id of the row where to read the
Mirror cell value or attribute.
If not set, it is set as the destination row.
When mirroring attributes, the MirrorRow should be the same kind as the source row (toolbar or row).
Or it can be special keyword:
Children_XXX - all immediate children. For reading returns the first one. If added _XXX, takes only children with given
D.
AllChildren_XXX - all children, deep. For reading returns the first one. If added _XXX, takes only children with given
D.
GroupChildren_XXX - all immediate children of the leaf child groups. For reading returns the first one. If added _XXX, takes only children with given
D.
GroupAllChildren_XXX - all children except groups, deep. For reading returns the first one. If added _XXX, takes only children with given
D.
Siblings_XXX - all siblings (without their children) in the same parent. For reading returns the first one. If added _XXX, takes only siblings with given
D.
Child_XXX - first suitable immediate child. If added _XXX as number, it returns the XXXth child, if added _XXX as string, returns first child with given
D.
Sibling_XXX - first suitable child in the parent. If added _XXX as number, it returns the XXXth child, if added _XXX as string, returns first child with given
D.
Next_XXX - first suitable next row. If added _XXX as number, it returns the XXXth child, if added _XXX as string, returns first child with given
D.
Prev_XXX - first suitable previous row. If added _XXX as number, it returns the XXXth child, if added _XXX as string, returns first child with given
D.
Parent_XXX - first suitable parent row. If added _XXX as number, it returns the XXXth parent (1st is the immediate parent), if added _XXX as string, returns first parent with given
D.
Grid_YYY_ZZZ - row ZZZ from grid YYY. It can also continue by the other keyword like
Grid_G2_Row123_Children.
It cannot be used for MirrorCol.
It can be set only directly to the cell, in object in A or in toolbar cell object.
id of the column where to read the
Mirror cell value or attribute.
If not set, it is set as the destination column.
Or it can be special keyword like in
MirrorRow.
If set, mirrors only given part of the cell value. MirrorPos can be an array of two values or string with two values comma separated.
It can be
[start,length] to read / write substring of the value from
start of
length characters.
Or it can be
[index,separator] to split the original value by
separator and read / write only value on given
index.
Grid method any
GetAttr
(Row row, Col col, string attr, bits direct = 0)
It is faster but less universal and safe than Get.
Returns attribute value. JavaScript type of the returned value is not specified and can be any suitable.
If
row is null, returns column attribute, if
col is null returns row attribute, otherwise returns cell attribute.
direct - what will be ignored, bit array:
1. bit &
1 - ignore JavaScript formula
{Attribute}Formula.
2. bit &
2 -
reserved.
3. bit &
4 - ignore
OnGetAttr API event.
4. bit &
8 - return direct attribute value, without any defaults. For cell returns value from
A, for row from
row, for column from
col.
row, col can be also Toolbar cell.
Grid method any
GetAttr
(object item, string attr)
Returns value of attribute
attr from object
item.
item can be row, column, toolbar or toolbar cell. It does
not call
OnGetAttr, just returns attribute from the object or from its
D
!! Grid method any
OnGetAttr
(Grid grid, Row row, Col col, string attr, any value, int direct)
Called to get raw value of any cell, row, column, toolbar and toolbar cell attribute.
It is called from
GetAttr with the same
row,
col,
attr and
direct parameters.
row or col can be null!
value is actual attribute value to be returned. Return
value or new attribute value.
Returning
null is the same as returning
value. To return null value return global constant
FGrid.Null.
Low level API event called many times.
Defining this event handler can slow down painting grid and cause choppy scrolling!
Grid method any
GetAttrs
(Row row, Col col, string[] attrs, int type = 0)
For
type =
0 returns all the values of attributes in
attrs in array.
For
type =
1 returns all the values of attributes in
attrs in object with these attributes set to their values. Cell value is set under "Value".
For
type =
2 returns first non null value of cell attribute from
attrs array.
If item in
attrs is empty, reads cell value. If the item in
attrs is "Value", reads only the "Value" attribute as default cell value.
Grid method bool
SetAttr
(Row row, Col col, string attr, any value, int changes = 0)
It is faster but less universal and safe than Set.
Sets
value to the attribute
attr.
If
row is null, sets column attribute, if
col is null sets row attribute, otherwise sets cell attribute.
Returns true if the attribute value was changed, false if the
value is the same as the attribute value (no change was done) and null for error.
If
value is null, clears the attribute value to its default value (except
changes =
2).
changes controls how the cell is marked as changed:
0 -
simple set - fast, does not mark or clear changes, does not store or change original value, does not test if the value is the same.
1 -
set and mark - marks changes, stores original value before the first change, tests if the value is the same.
If the
value is the same as original value, clears the marked changes.
2 -
set, mark and restore - like
2, but if
value is the same as default value sets null to use the default value and
if
value is
null restores original value and clears the marked changes.
3 -
set and clear - clears marked changes and clears original value, the new cell value is taken as original unchanged value. Returns false if the value is the same as actual value and no original value is stored.
4 -
set and test - like
0 but tests if the value is the same.
changes=
1/
2/
3 is forced to
4 if not set
second bit of
CellChanges (cell) /
ToolChanges (tool)
or 7th bit of
RowChanges (row) /
ColChanges (column).
The change is saved to Undo queue if
Undo contains "
Attr" and
changes is set.
row, col can be also Toolbar cell.
Grid method bool
ClearAttr
(Row row, Col col, string attr, any default, int changes = 0)
Clears the cell attribute value.
If the row and column have not set this attribute, it sets null to the cell attribute.
Otherwise it sets row.D or col.D attribute value or if null, the
def or if null, the 0 or "" depending on type of the attribute value in row / column.
It calls
SetAttr to set the attribute.
Grid method any
OnSetAttr
(Grid grid, Row row, Col col, string attr, any value, int changes)
Called before changing raw attribute value of any cell, row, column, toolbar and toolbar cell.
It is called from
SetAttr with the same
row,
col,
attr and
changes parameters.
value is value to be set to the attribute value. Return
value or new value to change it.
Returning
null is the same as returning
value. To return null value return global constant
FGrid.Null.
To cancel setting the attribute value return global constant
FGrid.Cancel.
Low level API event.
Grid method void
OnAfterSetAttr
(Grid grid, Row row, Col col, any value, int changes)
Called after changing raw attribute value of any cell, row, column, toolbar and toolbar cell.
It is called from
SetAttr with the same
row,
col,
attr and
changes parameters.
value is actual attribute value that has been set.
It is called only if the attribute value was really changed, so it is
not called after every
OnSetAttr call.
Low level API event.
Grid method any
GetCfgAttr
(string attr)
Returns Cfg and Grid attribute value.
Returns also custom attributes, but can be only values, not objects or functions.
Grid method bool
SetCfgAttr
(string attr, any value)
Sets Cfg and Grid attribute value to
value.
Can set also custom attributes, but only values, not objects or functions. No repaint request is done for custom attributes.
Returns true if the attribute was changed, false if it was the same and null for error.
The change is saved to Undo queue if
Undo contains "
Cfg".
Grid method bool
SetBookAttr
(string attr, any value, bool share = 0)
Sets Cfg and Grid attribute value to
value in all sheets in actual
Book.
If there is no
Book, sets just attribute of this grid like
SetCfgAttr.
Can set also custom attributes, but only values, not objects or functions. No repaint request is done for custom attributes.
If set
share, sets it to all sheets only if set
ShareCfg.
Returns true if the attribute was changed at least in one sheet, false if it was the same and null for error.
The change is saved to Undo queue if
Undo contains "
Cfg".
Grid method void
SetNewSheetAttr
(string attr, any value, bool share = 0, any item = null)
Sets Cfg and Grid attribute value to
value for all new sheets in actual
Book.
item can be Row, Col, Toolbar or Tool object or string as Part id to set the attribute for this item instead of Cfg.
If there is no
Book, does nothing.
Can set also custom attributes, but only values, not objects or functions.
If set
share, sets it to the new sheets only if set
ShareCfg.
Grid method any
GetTagAttr
(string tag, string attr)
Returns value of attribute
attr in given
tag. The
tag can be
Actions,
Text,
TextStyles,
Colors,
Borders,
Cursors.
Grid method bool
SetTagAttr
(string tag, string attr, any value)
Sets value of attribute
attr in tag
tag to
value.
The
tag can be
Actions,
Text,
TextStyles,
Colors,
Borders,
Cursors.
Returns true if the attribute was changed, false if it was the same and null for error.
It does not do any repaint! If required, call Repaint or FullRepaint.
Cell value and attributes set in short UTF8 Store format
UTF8 Store format can be used for very large grids to shorten size of downloaded data, reduce time for parsing downloaded data and remarkably reduce the required memory on client side to allocate for the data.
UTF8 Store format requires encoding on server side by function
WriteValue or
WriteValues.
Unicode string with values for all cells in the row.
It is used only if the cell value is not in
V (it is null or undefined).
It is much shorter and faster format than the
V.
It is read only, the changed values are saved to the
V.
All values in column must have the same data type and range set by
UCode value.
The cell position is set by
UIndex, the value size is set by
UCode,
all columns addressed in the
U must have set the
UIndex and
UCode.
The exact position of the cell value in
U is calculated by summary of data sizes (specified by
UCode) before the cell value.
The
U string should be encoded on server side using function
WriteValue or
WriteValues..
Col number
UIndex
[-1]
Column index to read cell values from Row
U.
The column must have set
UCode attribute.
If set to
-1, generates the value automatically if set
UCode.
If more columns have the same UIndex, they share the same value in rows'
U.
The automatically defined values are generated according to the order in data, generated are only not yet used indexes from 0.
Copied from default column on loading.
Col int
UCode
Data type and size of the column value in the
U.
The
UCode value is the data type number passed to function
WriteValue when generating the
U string.
Copied from default column on loading.
Col string[*]
Texts
First character separated array of all strings for row
U with
UCode.
This array is usually filled by the
WriteValue in
texts parameter.
Cfg string[*]
Texts
First character separated string or array of all strings for row
U with
UCode.
Global array used if the column has not set its
Texts.
Col string[*]
UTexts
First character separated string or array of all strings with encoded values for the second part of
UCode
Or for
UCode 0xC0 -
0xFF here are the second stored texts.
This array is usually filled by the
WriteValue in
utexts parameter.
Cfg bool
IgnoreDVOnU
If set, ignores
V attribute set in
default row for row with attribute
U set.
Unicode string with references to default attributes in
DefCells for all cells in the row.
It is used only if the
A does not contain reference to
DefCells.
It is much shorter and faster format than the
A.
It is read only, the changed attributes are saved to the
A.
The referenced items in
DefCells should be have number ids, not strings, for simple encoding.
The cell position is set by
BIndex, the value size is set by
BCode,
all columns addressed in the
B must have set the
BIndex and
BCode.
The
B string should be encoded on server side using function
WriteValue or
WriteValues..
Col number
BIndex
[-1]
Column index to read references to default cell attributes from Row
B.
The column must have set
BCode attribute.
If set to
-1, generates the value automatically if set
BCode.
If more columns have the same BIndex, they share the same value in rows'
B.
The automatically defined values are generated according to the order in data, generated are only not yet used indexes from 0.
Copied from default column on loading.
Col int
BCode
Data type and size of the references to default cell attributes in the
B.
The
BCode value is the data type number passed to function
WriteValue as
ucode when generating the
B string.
Usual
BCode value is
0x100 or
0x200.
Copied from default column on loading.
Col string[*]
BTexts
First character separated array of all strings for row
B with
BCode.
This array is usually filled by the
WriteValue in
texts parameter.
Cfg bool
IgnoreDAOnB
If set, ignores
A attribute set in
default row for row with attribute
B set.