Cell size
FastGrid documentation
Row height
Exact row height including padding and border, but excluding margin, in pixels.
a)
auto height. If not set (by default) or set to
0, it calculates the row height according to the cells content, but never below
RowHeight and
MinHeight and never above
MaxHeight.
Auto height is calculated as
PaddingTop + highest_text_height +
PaddingBottom + bottom_border.
b)
exact height. If set to
>=1, the row height is always exactly this value regardless other settings.
Default minimal auto height is
30 set by
RowHeight.
Default font size is 15px, so minimal possible row height with 1px border
without overflow single line text is
16.
For values below
16 the cell single line text will be vertically cut off, to let it to overflow to the row above (to display punctuation) use
OverflowTop.
Maximal row height including padding and border, but excluding margin, in pixels.
Applied when row is calculating its height according to its content (has not set
Height) or when resizing the row
Height by dragging or due
Rel.
Minimal row height including padding and border, but excluding margin, in pixels.
Applied when row is calculating its height according to its content (has not set
Height) or when resizing the row
Height by dragging or due
Rel.
Minimal row height when calculating its height according to its content (has not set
Height).
The higher value from
MinHeight and
RowHeight is applied as the minimal limit of the row auto height.
If the grid contains more columns than this value, the rows don't calculate their height according to the cell content.
It sets
RowHeight to all rows that have not set
Height.
If the row has set
Height to
0, it still calculates its height according to its content.
How many pixels the row text can overflow the row above. Used only if the row text is vertically cut off due too narrow row
Height to display the whole text.
It can be used to display the text punctuation in the top line.
It can be used for multi line overflown text or also in very narrow
Height for single line text.
For example
{ Height:14, OverflowTop:2, OverflowShift:1 } to display fully visible single line text in 14px rows and default 15px font size.
If set to
-1, it calculates the value automatically for the too narrow row height.
It cannot be used in the first row - it does not overflow the part.
How many pixels the row text will be shifted top when applied
OverflowTop. Ignored if
OverflowTop is set to
-1.
Use to speed up paint of overflown wrapped cells.
If set, the cell multi line text is overflown to the whole lines and it never shows partially cut off text.
If set, resizes / shrinks the row height to fill the whole part or grid height.
If more rows have set Rel attribute, their heights are resized according their Rel ratio.
It is used only if the part has set Rel > 0 or the part has set Fix with Height or MinHeight.
It is used only if the row has not set its Height. If the row is resized by dragging, the
Rel is temporary disabled until the row is resized under
ResizeAuto height to apply auto height.
Grid method int
GetHeight
(Row row)
Returns actual height of the row in pixels. For hidden row returns 0.
To get row Height attribute use GetAttr.
Grid method bool
SetHeight
(Row row, int height, bool changes = 0)
Sets the row
Height attribute to the
height value.
Returns true if the height was changed and paint is needed.
If set
changes stores original height for first time; if set
RowChanges&
32 marks the row changed; applies
ResizeOrig and
ResizeAuto.
Grid method void
SetRowHeight
(int rowheight)
Sets Cfg
RowHeight to the
rowheight.
Grid method int
GetRowTop
(Row row)
Returns vertical position of the
row in pixels inside its row part.
Column width
Exact column width including padding and border, but excluding margin, in pixels.
a)
auto width. If not set (by default) or set to
0, it calculates the column width according to the cells content, but never below
MinWidth and never above
MaxWidth.
The auto width is calculated according to cell with
Wrap&
3 =
0 or with
Wrap&
16 =
16. Up to
CalcWidthsRows is used to calculation.
The auto width is calculates from the wider cell according to text and icons width and spaces between, see the
horizontal content.
The auto width is not updated for changes by formulas or API, here is required to call RecalcWidth.
b)
exact width. If set to
>=1, the column width is always exactly this value regardless other settings.
Maximal column width including padding and border, but excluding margin, in pixels.
Applied when column is calculating its width according to its content (has not set
Width) or when resizing the column
Width by dragging or due
Rel.
Minimal column width including padding and border, but excluding margin, in pixels.
Applied when column is calculating its width according to its content (has not set
Width) or when resizing the column
Width by dragging or due
Rel.
If defined, used instead of
Width when exporting to xlsx.
How many rows will be used to calculate width of all columns without
Width set or set to
0.
The first half will be used from the first page and the rest will be used from all other pages averagely.
If set to
0 it uses all rows in grid.
The more rows are used, the slower is the width calculation.
If set, resizes / shrinks the column width to fill the whole part or grid width.
If more columns have set Rel attribute, their widths are resized according their Rel ratio.
If set to negative value, it is taken as positive and takes content width as minimal width.
It is used only if the part has set Rel > 0 or the part has set Fix with Width or MinWidth.
It is used only if the column has not set its Width. If the column is resized by dragging, the
Rel is temporary disabled until the column is resized under
ResizeAuto width to apply auto width.
Grid method int
GetWidth
(Col col)
Returns actual width of the column in pixels. For hidden column returns 0.
To get column Width attribute use GetAttr.
Grid method bool
SetWidth
(Col col, int width, bool changes = 0)
Sets the column
Width attribute to the
width value.
Returns true if the width was changed and paint is needed.
If set
changes stores original width for first time; if set
ColChanges&
32 marks the column changed; applies
ResizeOrig and
ResizeAuto.
Grid method bool
RecalcWidth
(Col col)
Sets the column to recalculate its auto width on the next
Paint.
Grid method int
GetColLeft
(Col col)
Returns horizontal position of the column
col in pixels inside its column part.
Resizing rows and columns
If rows can be resized by dragging the bottom edge in cell with
UseResize, by default cells in the Header / Index column.
If columns can be resized by dragging the right edge in cell with
UseResize, by default cells in the Header / Index row.
If set, the row height / column width cannot be changed by dragging.
If in given
column is possible to drag bottom cell edge to resize the
row.
If in given
row is possible to drag right cell edge to resize the
column.
By default it is set in
Index and
Header columns / rows.
If set in spanned cell, it will resize all rows in the spanned range.
1 - only visible and expanded rows,
2 - also collapsed children,
3 - all rows.
It should be set to all cells in the spanned range.
The rows to resize can be changed dynamically in
OnStartResize event.
If set in spanned cell, it will resize all columns in the spanned range.
1 - only visible and expanded columns,
2 - also collapsed children,
3 - all columns.
It should be set to all cells in the spanned range.
The columns to resize can be changed dynamically in
OnStartResize event.
If set and the row is resized, it sets its height to all rows with the same
D (or
DId) as the resized row. Also the row with DHeight do not save their Height to cookies, but save the Height with their default row instead.
If set to
1, it updates the other heights after resizing; if set to
2, it updates the other heights during resizing.
The rows with DHeight should all have the same height on start.
If set and the column is resized, it sets its width to all columns with the same
D (or
DId) as the resized column. Also the columns with DWidth do not save their Width to cookies, but save the Width with their default column instead.
If set to
1, it updates the other widths after resizing; if set to
2, it updates the other widths during resizing.
The columns with DWidth should all have the same width on start.
If defined, used for
DHeight /
DWidth instead of
D id.
Size of the cell edge that can be dragged to resize the column or row.
Size of the cell edge that can be dragged to resize the column or row. Used when dragging on touch screen.
Applied during resizing. If mouse moves more than the ResizeMaxDrag pixels in opposite direction than the resizing, the resized object size is returned to original value.
If resized column or row under this width / height (in pixels), its size is auto calculated according to the content.
If resized column or row under this width / height (in pixels), its size is restored to original value after last save (only if set
ColChanges&
32 /
RowChanges&
32).
API event bool
OnStartResize
(Grid grid, any src, int size)
Called before start resizing of the
src, it can be row or column object or row or column part id or array of row or column objects.
size is actual width or height of the
src. If
src is array, it is sum of all their widths.
src is array when resizing cell with
ResizeWidth or
ResizeHeight
If
src is array of rows or columns, it can be modified in this handler to resize different rows or columns.
Return true to
not start the resizing.
API event void
OnResize
(Grid grid, any src, int size, int origsize, int prevsize)
Called during resizing of the
src, it can be row or column object or row or column part id or array of row or column objects. Called many times for every change.
size is actual width or height of the
src.
origsize is original width or height of the
src before resizing.
prevsize is previous width or height of the
src from the last call on
OnResize.
If
src is array, the sizes are sums of all their widths.
API event int
OnEndResize
(Grid grid, any src, int size, int origsize)
Called after ended resizing of the
src, it can be row or column object or row or column part id or array of row or column objects.
size is actual width or height of the
src.
origsize is original width or height of the
src before resizing.
If
src is array, the sizes are sums of all their widths.
Return new value for
size or null to continue.
Padding
Space inside cell between cell text and cell edge without border.
Horizontal space in pixels between the text left edge and cell left edge (without border). Or space between text left edge and the right edge of the last icon before the text (
TextIcons or
LeftIcons).
Horizontal space in pixels between the text right edge and cell right edge (without border). Or space between text right edge and the left edge of the first icon after the text (
TextIcons or
RightIcons).
Vertical space in pixels between text top edge and cell top edge, in pixels (without border).
It is Row attribute unlike the cell attributes PaddingLeft / PaddingRight.
Vertical space in pixels between text bottom edge and cell bottom edge, in pixels (without border).
It is Row attribute unlike the cell attributes PaddingLeft / PaddingRight.
Margin
Space between columns and rows outside cells and their border.
Defining right and bottom margin separates the cell border to all edges.
Col int
MarginLeft
[0]
Empty space displayed left to the column, in pixels.
Setting left margin adds cell left border, so the adjacent columns have separated borders.
The left margin space is one pixels less due the added border.
Col int
LeftMarginLeft
[0]
Value added to
MarginLeft for first column in part.
Col int
FirstMarginLeft
[0]
Value added to
MarginLeft for first column on its level (first child).
Col int
BlockMarginLeft
[0]
Value added to
MarginLeft for first column in its
Block.
Color of the left margin space. It can be any CSS color or any color defined in
Colors object.
It can be also an object as list of CSS colors per row part, e.g.
MarginLeftColor: { Head:"#A0A0A0", Body:"#F0F0F0", Foot:"margin" }.
Col int
MarginRight
[0]
Empty space displayed right to the column, in pixels.
Setting right margin does
not add any cell border, so defining right margin without left margin of previous column displays empty space not separated from the cells by border.
Col int
RightMarginRight
[0]
Value added to
MarginRight for last column in part.
Col int
LastMarginRight
[0]
Value added to
MarginRight for last column on its level (last child).
Col int
BlockMarginRight
[0]
Value added to
MarginRight for last column in its
Block.
Color of the right margin space. It can be any CSS color or any color defined in
Colors object.
It can be also an object as list of CSS colors per row part, e.g.
MarginRightColor: { Head:"#A0A0A0", Body:"#F0F0F0", Foot:"margin" }.
Row int
MarginTop
[0]
Empty space displayed above the row, in pixels.
Setting top margin adds cell top border, so the adjacent rows have separated borders.
The top margin space is one pixels less due the added border.
Row int
TopMarginTop
[0]
Value added to
MarginTop for first row in part.
Row int
FirstMarginTop
[0]
Value added to
MarginTop for first row on its level (first child).
Row int
BlockMarginTop
[0]
Value added to
MarginTop for first row in its
Block.
Color of the top margin space. It can be any CSS color or any color defined in
Colors object.
The row margin color is preferred to column margin colors on crossings.
It can be also an object as list of CSS colors per column part, e.g.
MarginTopColor: { LeftCols:"#A0A0A0", Cols:"#F0F0F0", RightCols:"margin" }.
Row int
MarginBottom
[0]
Empty space displayed below the column, in pixels.
Setting bottom margin does
not add any cell border, so defining bottom margin without top margin of previous row displays empty space not separated from the cells by border.
Row int
BottomMarginBottom
[0]
Value added to
MarginBottom for last row in part.
Row int
LastMarginBottom
[0]
Value added to
MarginBottom for last row on its level (last child).
Row int
BlockMarginBottom
[0]
Value added to
MarginBottom for first row in its
Block.
Color of the bottom margin space. It can be any CSS color or any color defined in
Colors object.
The row margin color is preferred to column margin colors on crossings.
It can be also an object as list of CSS colors per column part, e.g.
MarginBottomColor: { LeftCols:"#A0A0A0", Cols:"#F0F0F0", RightCols:"margin" }.
Row, Col string / object
MarginRestColor
["header"/"margin"] GetAttr SetAttr
Color filled for
FillRest &
8 to empty space in row after the last cell, when used different column sets. It can be any CSS color or any color defined in
Colors object.
Default is "header" in Header rows and "margin" in other rows (set in column).
The Row attribute is preferred to Col if set both.
It can be also an object as list of CSS colors per column part (if set in row) or per row part (if set in column), e.g.
MarginRestColor: { LeftCols:"#A0A0A0", Cols:"#F0F0F0", RightCols:"margin" }.
If the margin belongs to the cell for mouse events.
0 - the margin space between cells is inactive for mouse. Hover cursor is hidden when mouse hovers the margin, so it can blink.
1 - the margin space between cells belongs to the cell and the cell gets mouse events done in the margin space.
2 - like
1 and also the margin space under the last row and right to the last column belongs to the last row / last column, when more column or row sets are used, so there is no inactive space in grid for margin.
It is not used when the part is wider or higher than its content due Fix.
Cfg bool
NoMargin
[0]
Set it in very large grid if no rows and columns have margin to speed up data initialization.
What will be filled in the rows after the last cell - if used more
column sets with different final widths. Bit array:
&
1 - row border (
RowBorder), &
2 - row background color (
Color),
&
4 - margin top / bottom (
MarginTop /
MarginBottom),
&
8 - row margin rest (
MarginRestColor, ignores &
1 and &
2).
It is not used when the part is wider or higher than its content due Fix or due different row sets - in this case the space will be always empty.
If the
left and
top border will be hidden or shown with cell margin.
Right and bottom cell border are shown regardless on margin.
0 - Left cell border is shown if left cell margin plus previous right cell margin is not zero.
Top cell border is shown if top cell margin plus previous bottom cell margin is not zero.
1 - Left cell border is shown if left cell margin is not zero.
Top cell border is shown if top cell margin is not zero.
2 - Left and top cell border is not shown for any margin.
Grid method void
UpdateMargin
(any part)
Updates margins after changing any
Margin... attribute in given
part.
part can be string as part id or row / column to update its part.
Cell span
Cells can be spanned horizontally through more columns and vertically through more rows. Only in the same part and set.
Defines cell column span in the row.
Defined as an object with values assigned to column ids. For example:
{ id:1, CS:{ C:2, G:3 } }
It supports also
Array and
String definition by
AIndex like
A attribute, but these definitions have slower processing and are used rarely.
If defined in default row, the values are copied to the rows' CS attributes on loading (only where the row CS item has null value), so later changes in default row do not change the cell spanning.
In case of violation with row span, the column span is preferred.
Using any CS can remarkably slow down very wide grid (with more than 100,000 columns) and the most of the columns hidden.
Col int[id]
CS
In rare cases cell column span can be defined also in columns or default columns.
These values are copied to the rows' CS attributes on loading (only where the row CS item has null value), so later changes of columns do not change the cell formulas.
If set, the row does not save its CS to cookies, but saves the CS with its default row instead.
Attribute for merging spanned cells. Breaks down the table structure and permits showing row cells with different widths than the table columns.
It is width of the spanned cell different than the column width.
If set, the next spanned cell is displayed directly next to this cell instead of in its column.
To take effect, the it must be set in the first spanned cell in the range and optionally in next spanned cells.
It is ignored if set in spanned cell that's previous cell has not set SpanWidth.
It can be set also in range (0.0 - 1.0) to calculate it as percentage of the whole spanned cell width.
It can be set to
0 to hide this cell, but test the next cells for the
SpanWidth.
It can be set to
-1 to calculate the
SpanWidth according to the cell content.
It can be set to
-2 to calculate the
SpanWidth as the rest of spanned cell width. If there are more cells with
SpanWidth<=-2, it is calculated according to the cell content. -2 is used also for the first null SpanWidth.
It can be set to
-3 or less to calculate the
SpanWidth as the rest of spanned cell width. If there are more cells with
SpanWidth<=-3, it is calculated as their ratio of the spanned cell width.
The merged cells are hovered, focused and edited individually, except if set
SpanCol.
For example SpanWidth is set as: A = 100, B = -2 (its text is 50px wide), C = -3, D = -6, E = 20, F = -1 (its text is 30px wide), G = null (its text is 10px wide), H = null and the whole spanned range is 300px wide.
The resulted widths inside spanned cell are A = 100, B = 50, C = (300-100-50-20-30-10)*-3/(-3-6) = 30, D = (300-100-50-20-30-10)*-6/(-3-6) = 60, E = 20, F = 30, G = 10, H = hidden.
Minimal width of the
SpanWidth cell. Used for
SpanWidth <
1.
If set in the first spanned cell in range with
SpanWidth, it hovers and focuses the spanned cell as whole and edits only the
SpanCol column cell.
The icons
LeftIcons /
TextIcons /
RightIcons in all merged cells are active, but control only the
SpanCol cell.
Controls the merged cells done by
SpanWidth.
How the
SpanCol will be used.
1.bit &
1 - If set, the other cells than
SpanCol under mouse will return the
SpanCol instead of the cell instead. It does not affec the side icons.
Grid method int
GetColSpan
(Row row, Col col)
Returns column span in the cell. For the first cell in the spanned range returns the range size.
For the next cells in the spanned range returns
0.
If the cell is not in spanned range, returns
1.
In row spanned range returns not zero values for all cells in the first column.
Grid method Col
GetSpanCol
(Row row, Col col, int type = 0)
Returns first column in the spanned range the cell is placed. If the cell is not spanned, returns
col.
For
type &
1 returns first visible column in the range. If there is no visible column, returns null.
For
type &
2 returns last (visible) column in the range.
Defines cell row span starting in the row.
Defined as an object with values assigned to column ids. For example:
{ id:1, RS:{ C:2, G:3 } }
It supports also
Array and
String definition by
AIndex like
A attribute, but these definitions have slower processing and are used rarely.
If defined in default row, the values are copied to the rows' RS attributes on loading (only where the row RS item has null value), so later changes in default row do not change the cell spanning.
In case of violation with column span, the column span is preferred.
Col int[id]
RS
In rare cases cell row span can be defined also in columns or default columns.
These values are copied to the rows' RS attributes on loading (only where the row RS item has null value), so later changes of columns do not change the cell formulas.
If set, the row does not save its RS to cookies, but saves the RS with its default row instead.
Grid method int
GetRowSpan
(Row row, Col col)
Returns row span in the cell. For the first cell in the spanned range returns the range size.
For the next cells in the spanned range returns
0.
If the cell is not in spanned range, returns
1.
In column spanned range returns not zero values for all cells in the first row.
Grid method Row
GetSpanRow
(Row row, Col col, int type = 0)
Returns first row in the spanned range the cell is placed. If the cell is not spanned, returns
row.
For
type &
1 returns first visible row in the range. If there is no visible row, returns null.
For
type &
2 returns last (visible) row in the range.
Grid method bool
Span
(Row row1, Col col1, Row row2, Col col2, bool split = 0, bool changes = 0)
Spans to one cell (
split =
0) or splits to individual cells (
split =
1) given cell range.
The
row1,
col1 can be any corner of the range and
row2,
col2 is the opposite corner.
If set
changes, marks the cell changed.
Returns true if the cell span was changed, false if not and null for error, if the range cannot be spanned or split.
Grid method bool
SplitCell
(Row row, Col col, bool changes = 0)
Splits given spanned cell to individual cells.
If set
changes, marks the cell changed.
Returns true if the cell span was changed, false if not and null for error.
Actions
Span
(int target = 0)
OnClickSpan
Spans together focused cells.
Actions
Split
(int target = 0)
OnClickSplit
Splits to individual cells all focused cells.
How the spanned cells will be colored for row and column state colors and for
Alternate row and column coloring.
0 - the row and column colors can go through spanned cells, so the spanned cell will have color strips, in case the top left cell has not set color by
Color.
1 - spanned cells are always colored only by top left cell
Color or by "span" color.
2 - spanned cells are colored by cell
Color or by "span" color merged with row and column state and alternate colors for the top left cell.
If set, it groups spanned rows and columns in the same parent to
Block (set by
negative number) and preserves their position inside the blocks for row and column manipulation and sorting, filtering and grouping.
&
1 - rows, &
2 - columns,
&
4 - sets also
Mirror for rows on move inside when the main spanned row changes,
&
8 - sets
Mirror for columns.
Mirror has less priority than Index, to use Mirror in Header it is required to turn off the Index.
If set, returns the main cell value for all spanned cell values, e.g. for sort, filter, group or for calculations.
&
1 - rows, &
2 - columns.
If set, checks crossing row and column span and removes the violating row span.
Set it to
0 to speed up span initialization if sure that there is no crossing span.
If set to
0, permits hiding the first row in row spanned range and show some of the rows.
Set it to
1 to speed up span update.