Grouping rows / columns
FastGrid documentation
Comma separated string or array of column ids to group rows by values in these columns. Or row ids to group columns by values in these rows.
If set to empty string, there is no grouping, but the part is controlled by toolbar with
Kind="Group" without
Part set.
By default is set to empty string in
Body part and not set in all other parts.
To show tree when grouping columns instead of rows there must be set ColTree=1.
Column id where to display the grouping tree, if the part has
not set
Tree attribute.
Or row id when grouping columns to display the grouped values.
It can be also set to object as named array of the column / row ids according to the
Group values. The array item id can be Regex string. The array item asterisk (*) is used for all not existing groupings.
For example:
GroupTree: { "A,B": "C", "A,.*": "D", "*": "A" }.
If set, shows different tree for every grouped column.
If set also
GroupTree as an object, it specifies tree column for every grouped column, e.g.
GroupTrees:1, GroupTree: {A:"A",B:"A",C:"C",D:"D"}.
It must be set RowTree = 2.
Exact column width including padding and border, but excluding margin, in pixels. Used instead of
Width for column showing grouping tree.
It can be set to
0 for auto width.
If set to
-1, the width of the column will be automatically increased by the widths of columns hidden by grouping.
It can be also set to object as named array of the column / row ids according to the
Group values. The array item id can be Regex. The array item asterisk (*) is used for all not existing groupings.
For example:
GroupWidth: { "A,B": 100, "A,.*": 150, "*": 200 }.
It is set to
1 for created group rows / columns for
GroupAdd =
1.
Set to row / column created by grouping.
If set, restricts grouping rows by values in this column or grouping columns by values in this row.
Set to column / row that's cells are used for grouping.
Which columns / rows will be hidden if this column / row is used for grouping.
It can be array or comma separated string of column (row) ids to hide.
If it is empty string or
0, it does not hide anything, only if set
HideGroupCols =
2, it hides the column / row itself.
If it is null, it hides the column / row itself.
Set to column / row that's cells are used for grouping.
If not set, the grouping settings can be changed, but grid is never grouped.
If set, hides all columns / rows that used for grouping rows, except if the column shows tree or tree column is an Index.
If set to
2, hides also columns / rows with
GroupHide = "".
Ignored if set GroupTrees or set GroupAdd = 0.
For
0 it creates the group row ids as
GroupRowIdPrefix + ascending number.
For
1 it creates the group row ids as column name +
GroupRowIdPrefix + grouping value.
For
2 it creates the group row ids as column name +
GroupRowIdPrefix + first child row id.
For
3 it creates the group row ids as row Level +
GroupRowIdPrefix + grouping value.
For
4 it creates the group row ids as row Level +
GroupRowIdPrefix + first child row id.
For
5 it creates the group row ids as parent id + "$" + column name +
GroupRowIdPrefix + grouping value.
For
6 it creates the group row ids as parent id + "$" + column name +
GroupRowIdPrefix + first child row id.
For
7 it creates the group row ids as parent id + "$" + row Level +
GroupRowIdPrefix + grouping value.
For
8 it creates the group row ids as parent id + "$" + row Level +
GroupRowIdPrefix + first child row id.
Prefix added before auto generated group row ids.
Starting number for auto generating group row ids
id.
When grid is re-grouped, the auto id is reset to this initial value.
Prefix added before auto generated group column ids.
Starting number for auto generating group column ids
id.
When grid is re-grouped, the auto id is reset to this initial value.
Comma separated string or array of items shown in Group menu. Set it to "" to not show the menu. It can contain "-" item as separator. Case sensitive. It can contain these keywords:
HideCols (
HideGroupCols, hides columns used for grouping),
Locale (
GroupLocaleCompare, ignore diacritics, switches only between 0 / 2 values),
White (
GroupWhiteChars, ignore white space),
Case (
GroupCaseSensitive, turn on case sensitive search),
Exclude (
GroupExclude, adds / removes "-" as the first character, creates groups for empty or other excluded values),
Single (
GroupSingle, creates groups for single values),
Sole (
GroupSole, creates single groups),
Deleted (
GroupDeleted, creates groups for deleted rows).
The menu controls only attributes set in Cfg, not the part attributes!
Toolbar string
D
= "Group"
Default toolbar to show actual grouping as individual header cells. With possibility to change the grouping by dragging cells or dropping header cells here.
It is possible to add new cells into
Cells, but the last cell should be always "
DropGroup".
It is possible to set
Part attribute to specify parts affected by this toolbar. If used for grouping columns, set
Accept =
Row.
For example:
{ D:"Group", Cells:[{ D:"GroupList", Width:50, List:{"":"none",A:"A",B:"B","A,B":"A+B","C,B,A":"C+B+A"} }, "DropGroup"] }
Tool string
D
= "DragGroup"
Default toolbar cell used by
Group toolbar to show every the dropped cell.
Do not use it explicitly, you can just modify it to change the toolbar cell look or behavior.
Tool string
D
= "DropGroup"
Default toolbar cell used by
Group toolbar to show the last empty space to drop cells here.
Do not use it explicitly, you can just modify it to change the last toolbar cell look or behavior.
Tool string
D
= "GroupList"
Default toolbar cell to show actual grouping and to choose another grouping from popup list.
Set
List attribute to the list, e.g.
{ D:"GroupList", Width:50, List:{"":"none",A:"A",B:"B","A,B":"A+B","C,B,A":"C+B+A"} }
It can be, but need not be, placed to
Group toolbar.
Tool string
D
= "Group"
Default toolbar cell to show Group icon to switch on / off grouping (
Grouped) and to show grouping options defined by
GroupMenu.
It can be, but need not be, placed to
Group toolbar.
Grid method any
GetGroup
(string part = null, bool array = 0)
Returns actual grouping for given
part.
part can be comma separated string or array of part ids.
If
part is not set, returns the first not null value of
Group value in any part.
For
array =
0 return comma separated string, for
1 returns array.
Grid method void
SetGroup
(string group = null, string part = null)
Sets or clears the grouping for given
part.
part can be comma separated string or array of part ids.
If
part is not set, sets Group value of all parts with non null value in
Group.
group can be comma separated string or array of column / row ids to group by.
If
group is empty string or null, clears the grouping for given
part.
It can be run asynchrounsly when applied SyncRows.
Grid method void
ReGroup
(string part = null)
Groups given
part again without changing the settings.
part can be comma separated string or array of part ids.
If
part is not set, re-groups all parts with non null
Group attribute.
It can be run asynchrounsly when applied SyncRows.
API event bool
OnGroup
(Grid grid, string part, string group, string oldgroup)
Called before the grid part is grouped.
part is the part id
id,
group is comma separated string with new grouping, it can be empty string for ungroup.
oldgroup is comma separated string with old grouping, it can be empty string.
Return true to not group the part.
If called the OnGroup, the OnSort is not called when sorting after the grouping is done.
API event void
OnGrouped
(Grid grid, string part, string group, string oldgroup, string oldtree)
Called after the grid part is grouped and sorted.
part is the part id
id,
group is comma separated string with new grouping, it can be empty string for ungroup.
oldgroup is comma separated string with old grouping, it can be empty string.
oldtree is string as column id as previous
Tree attribute when grouping row part.
If called the OnGrouped, the OnSorted is not called when sorting after the grouping is done.
API event string
OnGetGroupD
(Grid grid, string groupcol, string group, Row / Col first)
Called to get group
D id for every generated group row (or group column when grouping columns).
groupcol is column id the group row is created for (or row id the group column is created for).
group is the
Group string with actual grouping.
first is the first data (not group) child row (or column) the group will have.
Return string as the group default id. Default is "Group".
The returned group default must be derived from the Group default or have set Group attribute to 1.
API event string / int
OnGenerateId
(Grid grid, object item, string / int id, int type)
Called when generating id for any row, column, toolbar or toolbar cell in grid.
It is
not called if the item has set its unique id.
type is
item kind:
0 - row,
1 - column,
2 - group row,
3 - goup column,
4 - toolbar,
5 - toolbar cell.
Grid method void
SetHideGroupCols
(int value)
Sets
value to
HideGroupCols and shows / hides the columns.
Grid method Col
GetGroupCol
(Row row)
Returns column according to the group
row is created. For normal row returns null.
Grid method Row
GetGroupRow
(Col col)
Returns row according to the group
col is created. For normal column returns null.
Grid method int
GetGroupPos
(Row row)
Returns
row position (from 0) when there are created more groups for one columns by
GroupChar or
GroupMaxChars.
Grouping settings
If the row or column is removed from grouping - it cannot be moved to the group row / column and the grouping processes the row / column children.
Set to row / column being grouped.
Value used instead of cell value for grouping and sorting.
Set to row / column cell being grouped.
List of values for them will
not be created groups. Array or string as first character separated array.
For excluding empty value set:
"|", for excluding empty and zero set:
"||0".
If starts by "-", it is ignored, but can be set on in
GroupMenu.
If creates group for single values (the value is unique in its range).
If creates single group rows (all values have the same value in their range).
If groups also deleted rows / columns.
0 - no, the deleted items have set
NoGroup.
1 - yes, but only if the rows / columns are visible by
DeletingRows /
DeletingCols.
2 - yes, always, it can produce empty groups if the deleted rows / columns are hidden.
For
0 does not create any group rows (columns), but makes next rows (columns) in group as children of the first row (column).
If and on which level will be the created groups collapsed.
null or "" - does not control the collapse level, it is controlled by
Collapsed attribute of created groups,
0 - expand all,
1 - collapse all,
2 - collapse second level, ...
The Toolbar cell Group menu item is enabled only if GroupCollapsed is set to
0 or
1.
It is possible to create more or all grouping levels from one column / row. Specify GroupChar as separator.
It can be used for example to group by directory paths, set GroupChar='/'.
The cell value is split by the GroupChar and is grouped by all the parts.
Remember, by default also empty values and string parts are grouped by, see
GroupExclude.
Maximum characters from strings to compare. It should be set only for string columns/ rows.
It can be used to group by according to first few characters.
It can contain more comma separated values to create more group levels according to given parts of the values.
For example GroupMaxChars='1,2,3,4' creates up to four levels by the first four characters.
For example GroupMaxChars='2,6' creates up to two levels, the first by first two characters, the second by next four characters.
When used GroupMaxChars, it is better to not hide the grouped column, by setting it as GroupMain or by setting its CanGroup='2'.
If set to
1, uses for sorting the values from
List, if defined.
Slows down the sorting.
If set to
2, uses for sorting and grouping the values from
List, if defined.
Slows down the sorting and grouping.
If not set, ignores the list and uses always the raw cell value for sorting and grouping.
If set to column id, it groups by this column instead of actual column when dragged the column to Group row.
Comparing strings
If the strings in grouping are compared as case sensitive.
Used only if the row, column has not set the CaseSensitive attribute.
If the strings are compared as case sensitive.
For sorting and grouping it can be set only to row or column, for filtering it can be set also to filter cell and for generated List by *Rows / *Cols also to the cell with the List.
If set, compares strings in grouping according to locale meaning.
Used only if the row, column has not set the LocaleCompare attribute.
0 | a<b<á | according to unicode |
1 | a<á<b | according to default locale |
2 | a==á<b | according to default locale |
"locale" | a<á<b | according to specified locale (e.g. "en-US" or "cs-CZ") |
"=locale" | a==á<b | according to specified locale (e.g. "=en-US" or "=cs-CZ") |
If set, compares strings according to locale meaning.
0 | a<b<á | according to unicode |
1 | a<á<b | according to default locale |
2 | a==á<b | according to default locale |
"locale" | a<á<b | according to specified locale (e.g. "en-US" or "cs-CZ") |
"=locale" | a==á<b | according to specified locale (e.g. "=en-US" or "=cs-CZ") |
For sorting and grouping it can be set only to row or column, for filtering it can be set also to filter cell and for generated List by *Rows / *Cols also to the cell with the List.
List of characters to ignore when comparing strings for grouping.
Used only if the row, column has not set the WhiteChars attribute.
It can be set for example to " " (space) to ignore spaces (it means that for example "a b c" and "abc" strings are the same.
If starts by "-", it is ignored, but can be turned on in
GroupMenu.
List of characters to ignore when comparing strings.
It can be set for example to " " (space) to ignore spaces (it means that for example "a b c" and "abc" strings are the same.
For sorting and grouping it can be set only to row or column, for filtering it can be set also to filter cell and for generated List by *Rows / *Cols also to the cell with the List.
It changes characters in comparing strings.
It is first character separated array of pair of characters to replace the first character by the second one when comparing strings.
For example "|y|i|Y|I|.|," - replaces 'y' by 'i', 'Y' by 'I' and '.' by ','
- it means that when comparing strings does not differ between letter 'y' and 'i', both cases and also does not differ between comma and point.
The first character must be one letter, but the second in fact can be any letter or string or even empty string, like "|a|xxx|b||c|ff".
For sorting and grouping it can be set only to row or column, for filtering it can be set also to filter cell and for generated List by *Rows / *Cols also to the cell with the List.
If set, removes all HTML code when comparing strings during sorting, grouping and filtering.
For sorting and grouping it can be set only to row or column, for filtering it can be set also to filter cell and for generated List by *Rows / *Cols also to the cell with the List.
Pivot grid
Creating pivot grid from source data, as 2D grouping into rows and columns.
For grouping pivot uses group attributes from
pivot grid:
GroupExclude,
GroupSingle,
GroupSole,
GroupDeleted,
GroupCaseSensitive,
GroupLocaleCompare,
GroupWhiteChars.
If set
PivotOptions&
8 uses these group attributes from pivot
source grid.
Comma separated string or array of column ids in pivot
source grid to group by them to pivot rows.
Pivot grid attribute.
Comma separated string or array of column ids in pivot
source grid to group by them to pivot columns.
Pivot grid attribute.
Comma separated string or array of column ids in pivot
source grid to display their summaries in pivot data.
Pivot grid attribute.
If the column id starts by "-", the column is created hidden - it can be used for calculating group summaries.
Comma separated string or array of row part ids in pivot
source grid to read pivot source data from.
Pivot grid attribute.
FastGrid formula used to calculate the pivot data cells from source grid cells. It can use the same variables as standard
JavaScript formula.
The
Grid variable is the pivot grid,
Grid.DataSource is the source grid,
Row,
Col is the calculated cell in the pivot grid,
Calc.Col is the column summed in the source grid.
Pivot grid attribute.
If and how will be mirrored single
PivotData cells. Sets to the cells an attribute
Mirror with this value.
Pivot grid attribute.
Pivot grid attribute.
1. bit &
1 - If set, displays all column ids in one pivot header and hides other pivot headers. They can be shown in Layout menu.
2. bit &
2 - If set, does not hide the Collapse buttons in pivot headers when shown also column Tree.
3. bit &
4 - If set, clears pivot grid
Hidden attribute on create pivot and sets it on create empty pivot. Shows the pivot tab on sheets toolbar only if it has data.
4. bit &
8 - If set, hides Sheets toolbar when pivot grid has no data.
5. bit &
16 - If set, uses Group settings from source grid instead of pivot grid. Shares group settings with the source grid.
If set, the pivot settings can be changed, but pivot is not created. Disabled pivot to change more settings at once without creating pivot for every change.
Pivot grid attribute.
Comma separated string or array of items shown in Pivot menu. Set it to "" to not show the menu. It can contain "-" item as separator. Case sensitive. It can contain these keywords:
Pivot options:
Headers (
PivotOptions, 1.bit &
1, shows all column captions in one row or in more rows per level),
ColTree (
PivotOptions, 2.bit &
2, shows column tree in headers or in separate part),
Collapse (
PivotOptions, 5. bit &
16, collapses created groups),
Shared grouping options:
Exclude (
GroupExclude, adds / removes "-" as the first character, creates groups for empty or other excluded values),
Locale (
GroupLocaleCompare, ignore diacritics, switches only between 0 / 2 values),
White (
GroupWhiteChars, ignore white space),
Case (
GroupCaseSensitive, turn on case sensitive search),
Single (
GroupSingle, creates groups for single values),
Sole (
GroupSole, creates single groups),
Deleted (
GroupDeleted, creates groups for deleted rows).
The menu controls only attributes set in Cfg, not the part attributes!
id of the pivot grid that will be filled by data from this source grid by the
CreatePivot.
Source grid attribute.
If set, the column cannot be dragged to appropriate Pivot toolbars.
Source grid attribute.
&
1 - no PivotRows, &
2 - no PivotCols, &
4 - no PivotData.
Grid method void
CreatePivot
(string rows = null, string cols = null, string data = null, bool show = 0, Grid grid = null, string part = null)
Creates pivot from pivot source grid.
It can be called as a method of pivot grid or of pivot source grid.
If
rows is null, it is read from
PivotRows. Otherwise it is saved to
PivotRows.
If
cols is null, it is read from
PivotCols. Otherwise it is saved to
PivotCols.
If
data is null, it is read from
PivotData. Otherwise it is saved to
PivotData.
If set
show, shows the pivot sheet and hides the pivot source grid.
grid can be set to pivot grid, if there are more pivot grids for the source grid.
part can be set to row part id in source grid to be used as source data. If not set, the
DefRowPart is used.
It can be run asynchrounsly when applied SyncRows.
API event bool
OnPivotCreate
(Grid pivot, Grid source, string rows, string cols, string data, string part, bool show)
Called before the
pivot grid is filled by pivot data from
source grid.
rows is actual
PivotRows,
cols is actual
PivotCols,
data is actual
PivotData,
part is actual
PivotPart.
If
show is set, the
pivot sheet will be shown instead of
source sheet.
Return true to cancel the action.
API event bool
OnPivotCreated
(Grid pivot, Grid source, string rows, string cols, string data, string part, bool show)
Called after the
pivot grid is filled by pivot data from
source grid, but before it is shown.
rows is actual
PivotRows,
cols is actual
PivotCols,
data is actual
PivotData,
part is actual
PivotPart.
If
show is set, the
pivot sheet will be shown instead of
source sheet.
Return true to not show the
pivot grid when
show is set.
Grid method Grid
GetPivotGrid
( )
Returns Pivot grid for this source grid. If the calling grid is pivot grid or there is no pivot grid, returns the calling grid.
Grid method Grid
GetPivotSource
( )
Returns source grid for this pivot grid. If the calling grid is source grid or there is no pivot grid, returns the calling grid.