API
FastGrid documentation
API for iterating rows and columns
Grid method any
Iter
(Row / Col item, any func = null, bits type = 0, bits rev = 0, int max = null, Row / Col next = null, string / int set = null)
Main complex method to iterate rows and columns in order they are defined in data and displayed in grid. It is remarkably faster than using
GetNext /
GetPrev methods.
Iterates all rows / columns from
item to
next or
max or part end and calls function
func for every the row column.
item is the row / column the iteration starts from. It is included in result only if set
rev&
2 and it fulfills
type conditions.
item can be
string as part id to start by the first (or last for
rev&
1) item in this part. The first / last item is included in result regardless on
rev&
2, but still must fulfill
type conditions.
next is the row / column the iteration ends on. It is included in result only if set
rev&
4 and it fulfills
type conditions.
max is maximum rows to iterate. If the maximum is reached, iteration ends. It includes
item /
next only if set the
rev&
2 /
4.
If
set is
null (default), it iterates only the same part as
item and the
NextPart /
PrevPart, the same row / column set as
item.
If
set is
-1, it iterates also all the next parts, the same row / column set as
item.
If
set is
-2, it iterates only this part and ignores
NextPart /
PrevPart. Iterates only the same row / column set as
item.
If
set is set to row / column set id or index (from 0), it iterates this set, also all the next or previous parts.
type&
1 - only visible,
type&
2 - ignores collapsed children,
type&
4 - only on the same tree level in the same parent,
type&
8 - only leaf children (items without children).
rev&
1 - iterates backwards from end to start,
rev&
2 - includes
item in result,
rev&
4 - includes
next in result.
func is JavaScript
function as
func(
Row /
Col item,
int pos). The
item is the iterated row / column and
pos is its number in iteration, from 0.
If the function
func returns true, the iteration ends. The function
func must not change order and count of rows / columns in grid.
If
func is
null, the Iter returns all iterated rows / columns in array.
If
func is
array, the Iter adds iterated rows / columns to this array and returns it.
If
func is
1, the Iter only counts the rows / columns and returns their count.
Iter returns count of iterated rows / columns. Or returns array of iterated rows, if
func is null or array.
Examples:
rows = grid.Iter(row1,null,0,6,row2) - rows contains all rows between and including row1 and row2.
count = grid.Iter("Body",null,1) - returns count of all visible rows in Body part.
found = null; grid.Iter(row2,function(row,pos){ if(grid.GetValue(row,grid.Cols.A)=="xxx"){ found = row; return true; } },0,7,row1) - sets to found variable the first row with value "xxx" in column A, between row1 and row2, searches backwards.
Grid method any
IterChildren
(Row / Col item, any func = null, bits type = 0, bits rev = 0, int max = null)
Iterates all child rows of parent
item. If set
rev&
2, it includes the
item to result too.
If set
rev&
1, it iterates always forwards, from top (left) to bottom (right). Otherwise it iterates backwards if set
ReversedTree.
func,
type and
max parameters are the same as in
Iter.
Grid method any
IterSimple
(Row / Col item, function func, bool include = 0)
Iterates all rows / columns from
item and calls for every item the function
func(
Row / Col item). Stops on part end when the
func returns true.
If set
include, calls function
func also for the start
item. Iterates only one part set, ignores
NextPart.
Simple faster version of the Iter method.
Grid method any
IterAll
(string part, function func)
Iterates all rows (
part = "R" / null), columns (
part = "C"), toolbars (
part = "T") or all items in
part (including
PrevPart and
NextPart parts),
part can be also toolbars part.
For every iterated item calls
func(
Row / Col / Toolbar item). Ends if the
func returns true.
If the
func is null, returns all iterated items in array.
Simple faster version of the Iter method.
Grid method any
Count
(string part, bits hidden = 0, string / int set = 0)
Returns count of rows / columns in given
part. Counts in only one part set, ignores
NextPart.
If set
hidden, ignores given rows / columns: &
1 - manually hidden, &
2 - filtered, &
4 - collapsed children.
If set
set as set id or index from 0, iterates this set. Otherwise iterates the first set.
Grid method Row / Col
GetFirst
(string part = null, bits type = 0, string / int set = null)
Returns the first row / column from given
part. If the part has set
PrevPart, it returns the first row / column from the parts chain.
If the
part is null or "
R", returns the first row in grid. If the
part is "
C", returns the first column in grid.
type&
1 - first visible,
type&
2 - ignores collapsed children (in reversed tree),
type&
4 - first root row / column (in reversed tree).
If
set is set, returns the first row / column from this row set / column set from the
part. The
set is the set id or index from 0.
Grid method Row / Col
GetFirstVisible
(string part = null, string / int set = null)
Returns the first row / column from given
part. Returns the same result as
GetFirst with
type =
3, but it is faster for many hidden rows.
Grid method Row / Col
GetLast
(string part = null, bits type = 0, string / int set = null)
Returns the last row / column from given
part. If the part has set
NextPart, it returns the last row / column from the parts chain.
If the
part is null or "
R", returns the last row in grid. If the
part is "
C", returns the last column in grid.
type&
1 - last visible,
type&
2 - ignores collapsed children,
type&
4 - last root row / column.
If
set is set, returns the last row / column from this row set / column set from the
part. The
set is the set id or index from 0.
Grid method Row / Col
GetLastVisible
(string part = null, string / int set = null)
Returns the last row / column from given
part. Returns the same result as
GetLast with
type =
3, but it is faster for many hidden rows.
Grid method Row / Col
GetNext
(Row / Col item, bits type = 0, string / int set = null)
Returns the next row / column after row / column
item.
type&
1 - only visible,
type&
2 - ignores collapsed children,
type&
4 - only on the same tree level in the same parent,
type&
6 - only on the same or lower tree level.
If
set is
null (default), it returns only from the same part or from the
NextPart, from the same row / column set as
item.
If
set is
-1, it returns also from all the next parts, from the same row / column set as
item.
If
set is
-2, it returns only from this part and ignores
NextPart. From the same row / column set as
item.
If
set is set to row / column set id or index (from 0), it returns from this set, also from all the next parts.
Grid method Row / Col
GetNextVisible
(Row / Col item, string / int set = null)
Returns the next visible row / column after row / column
item. Returns the same result as
GetNext with
type =
3, but it is faster for many hidden rows.
Grid method Row / Col
GetPrev
(Row / Col item, bits type = 0, string / int set = null)
Returns the previous row / column before row / column
item.
type&
1 - only visible,
type&
2 - ignores collapsed children,
type&
4 - only on the same tree level in the same parent,
type&
6 - only on the same or lower tree level.
If
set is
null (default), it returns only from the same part or from the
PrevPart, from the same row / column set as
item.
If
set is
-1, it returns also from all the previous parts, from the same row / column set as
item.
If
set is
-2, it returns only from this part and ignores
PrevPart. From the same row / column set as
item.
If
set is set to row / column set id or index (from 0), it returns from this set, also from all the previous parts.
Grid method Row / Col
GetPrevVisible
(Row / Col item, string / int set = null)
Returns the previous visible row / column before row / column
item. Returns the same result as
GetPrev with
type =
3, but it is faster for many hidden rows.
Grid method Row / Col
GetFirstChild
(Row / Col item, bits type = 0)
Returns the first child row / column of the
item. If set
ReversedTree, returns the top / left child,
not the child above / right part.
type&
1 - first visible,
type&
2 - ignores collapsed children (in reversed tree),
type&
4 - first immediate child (in reversed tree).
Grid method Row / Col
GetLastChild
(Row / Col item, bits type = 0)
Returns the last child row / column of the
item. If set
ReversedTree, returns the child above / right to the
item,
not the top / left child.
type&
1 - first visible,
type&
2 - ignores collapsed children (in reversed tree),
type&
4 - first immediate child (in reversed tree).
Grid method Row / Col
GetParent
(Row / Col item)
Returns parent row / column of the
item.
Grid method Row / Col
GetFirstView
(string part = null, int min = 0, string / int set = null)
Returns the first row displayed on the top of actual view of the part. The row can be displayed partially, overflowed from top by
min pixels.
Or returns the first column displayed on the left in actual view of the part. The column can be displayed partially, overflowed from left by
min pixels.
If
set is set, returns the first row / column from this row set / column set from the
part. The
set is the set id or index from 0.
Grid method Row / Col
GetLastView
(string part = null, int min = 0, string / int set = null)
Returns the last row displayed on the bottom of actual view of the part. The row can be displayed partially, overflowed from bottom by
min pixels.
Or returns the last column displayed on the right in actual view of the part. The column can be displayed partially, overflowed from right by
min pixels.
If
set is set, returns the first row / column from this row set / column set from the
part. The
set is the set id or index from 0.
Grid method Row / Col
GetOnPoint
(string part, int pos, bool hidden = 0, string / int set = null)
Returns row / column / toolbar cell on given position
pos in pixels in given row part / column part / Toolbar
part. For hidden row / column and
hidden =
0 returns next visible row / column.
part is id of the part. If
part is null, uses default row part. If
set is set, returns the row / column from this row set / column set from the
part. The
set is the set id or index from 0.
Paint & repaint
Grid method void
Paint
( )
Paints the grid, repaints all pending changes since last call of the
Paint.
It is automatically called after finish of every FastGrid event.
It must be called manually after changed anything in grid outside FastGrid event to display the changes.
Paint can be called more times, it is very fast, if there are no pending repaint changes.
Grid method void
Repaint
(any part = null, int clear = 0)
Schedules given
part to repaint on the next
Paint.
The function is very fast and can be called many times.
part can be string as the row / col part id or Row or Col or Toolbar object to repaint its part. If the
part is null, repaints all parts in grid.
For
clear =
0, it repaints only background. For
clear =
1 it repaints also texts (use when any text or its position changes). For
clear =
2 also recalculates all formulas. For
clear =
3 also repaints the whole grid.
It is possible to call also without part as Repaint(int clear).
Calling Repaint is usually not needed when using FastGrid API in standard way.
Grid method void
RepaintToolbars
(int clear = 0)
Schedules all toolbars to repaint on the next
Paint.
The function is very fast and can be called many times.
For
clear =
0, it repaints only background. For
clear =
1 it repaints also texts (use when any text or its position changes).
It always recalculates all toolbar formulas.
Calling RepaintToolbars is usually not needed when using FastGrid API in standard way.
Grid method void
FullRepaint
(any part)
Schedules everything in grid to repaint and recalculate on the next
Paint.
The function is very fast and can be called many times.
If set
part, marks only this part to repaint the
part can be part id or row / column in the part.
Calling FullRepaint is usually not needed when using FastGrid API in standard way.
Grid method void
Update
(bits type = 0, DOMEvent event = null)
Updates layout size, relative widths and heights, auto parts, etc.
Calls
Paint except if set
type&
1.
If set
type&
2 calls also
ApplyMedia on beginning.
Calling Update is usually not needed when using FastGrid API in standard way.
API event void
OnPaint
(Grid grid)
Called before the grid is painted.
API event void
OnPainted
(Grid grid)
Called after the grid is fully painted.
If the grid contains more rows than this limit, some features liks Sort, Filter, Group, Pivot are run asynchronously with modal message shown in grid during the action.
Various API methods
Grid method void
Later
(function func, any[] parameters = null, string name = null)
Schedules calling the function
func later just before next
Paint.
It is not the same as setTimeout, Later calls the function func in the same timeframe without any delay.
To show message and do the func in timeout use ShowMessageLater instead.
If more
Later were called, the functions are called in the same order as the
Later calls.
If set
name, the function
func is scheduled only if there is not any pending scheduled function with the same
name.
The
parameters is an array of parameters the function
func receives.
The func is called as a method of the Grid object.
Grid method void
LaterPaint
(function func, any[] parameters = null, string name = null)
The same as
Later, but calls the function
after next
Paint and after its finish runs the
Paint again.
FGrid function object
GetDocument
(Grid grid = null)
Returns shadow root document for given
grid to use its methods like getElementById() or querySelector().
If
grid is null, returns shadow root document for messages and dialogs.
If shadow is not used, returns DOM document.
FGrid variable bits
Browser
Returns actual browser type: &
1 - tablet (0 = desktop), &
2 - WebKit (Chrome, Edge, Opera, ...), &
4 - Firefox, &
8 - strict mode (0 = quirks mode).