Using Rows at Runtime
At runtime, the columns.render
function and a lot
of
other
functions use the rowInfo
object to access the current row and use it to decide how to render the current cell or row.
The rowInfo
object has a few variations, depending on the presence or absence of grouping. See type definition here.
Note
All those variations are discriminated in the TypeScript
typings, so you can easily use the different types of rowInfo
objects.
Ungrouped Scenario - normal rowInfo
When there is no grouping
, the rowInfo
object has the following properties:
data
- type:DATA_TYPE
dataSourceHasGrouping
- type:false
isGroupRow
- type:false
id
- type:any
. The id of the row, as defined by theidProperty
prop.selfLoaded
- type:boolean
. Useful in lazy-loading scenarios, when there is batching present. If you're not in such a scenario, the value will befalse
. You can use this to show a loading indicator for the row.indexInAll
- typenumber
. The index of the row in the full dataset. Called like this because for grouping scenarios, there's also anindexInGroup
Discriminator
rowInfo.dataSourceHasGrouping === false;
Grouped scenario - normal rowInfo
When there is grouping
defined, and the row is not a group row, the rowInfo
object has the following properties:
data
- type:DATA_TYPE
dataSourceHasGrouping
- type:true
isGroupRow
- type:false
indexInAll
- like the aboveindexInGroup
- type:number
. The index of the row in its parent group.groupKeys
- type:any[]
, but usually it's actuallystring[]
. For normal rows, the group keys will have all the keys starting from the topmost parent down to the last group row in the hierarchy (the direct parent of the current row).
Example: People grouped by country and city
> Italy - country - groupKeys: ['Italy']
> Rome - city - groupKeys: ['Italy', 'Rome']
- Marco - person - groupKeys: ['Italy', 'Rome']
- Luca - person - groupKeys: ['Italy', 'Rome']
- Giuseppe - person - groupKeys: ['Italy', 'Rome']
groupBy
- type(keyof T)[]
. Has the same structure as groupKeys, but it will contain the fields used to group the rows.rootGroupBy
- type(keyof T)[]
. The groupBy value of the DataSource component, mapped to thegroupBy.field
parents
- a list ofrowInfo
objects that are the parents of the current row.indexInParentGroups[]
- type:number[]
. See below for an example
> Italy - country - indexInParentGroups: [0]
> Rome - city - indexInParentGroups: [0,0]
- Marco - person - indexInParentGroups: [0,0,0]
- Luca - person - indexInParentGroups: [0,0,1]
- Giuseppe - person - indexInParentGroups: [0,0,2]
> USA - country - indexInParentGroups: [1]
> LA - city - indexInParentGroups: [1,0]
- Bob - person - indexInParentGroups: [1,0,2]
groupCount
- type:number
. The count of leaf rows that the current group (in this case, the parent group) containsgroupNesting
- typenumber
. The nesting of the parent group.collapsed
- typeboolean
.selfLoaded
- type:boolean
. Useful in lazy-loading scenarios, when there is batching present. If you're not in such a scenario, the value will befalse
.
Discriminator
rowInfo.dataSourceHasGrouping === true && rowInfo.isGroupRow === false;
Grouped scenario - group rowInfo
When there is grouping
defined, and the row is a group row, the rowInfo
object has the following properties:
data
- type:Partial<DATA_TYPE> | null
. Thedata
object that might be available is the result of theaggregation reducers
. If none are specified,data
will benull
dataSourceHasGrouping
- type:true
isGroupRow
- type:true
error
- type:string?
. If there was an error while loading the group (when the group row is expanded), this will contain the error message. If the group row was loaded with thecache: true
flag sent in the server response, the error will remain on therowInfo
object even when you collapse the group row, otherwise, ifcache: true
was not present, theerror
property will be removed on collapse.indexInAll
- like the aboveindexInGroup
- type:number
. The index of the row in the its parent group.deepRowInfoArray
- an array ofrowInfo
objects. This array contains all the (uncollapsed, so visible) row infos under this group, at any level of nesting, in the order in which they are visible in the table.reducerResults
- typeRecord<string, AggregationReducerResult>
. The result of theaggregation reducers
for each field in theaggregationReducers
prop.groupCount
- type:number
. The count of leaf rows that the current group (in this case, the parent group) containsgroupData
- type:DATA_TYPE[]
. The array of the data of all leaf nodes (normal nodes) that are inside this group.
Example: People grouped by country and city
> Italy - country - groupKeys: ['Italy']
> Rome - city - groupKeys: ['Italy', 'Rome']
- Marco - person - groupKeys: ['Italy', 'Rome']
- Luca - person - groupKeys: ['Italy', 'Rome']
- Giuseppe - person - groupKeys: ['Italy', 'Rome']
collapsedChildrenCount
- type:number
. The count of all leaf nodes (normal rows) inside the group that are not being visible due to collapsing (either the current row is collapsed or any of its children)directChildrenCount
- type:number
. The count of the direct children of the current group. Direct children can be either normal rows or groups.directChildrenLoadedCount
- type:number
. LikedirectChildrenCount
, but only counts the rows that are loaded (when batched lazy loading is configured).childrenAvailable
- type:boolean
. For lazy/batched grouping, this is true if the group has been expanded at least once. NOTE: if this is true, it doesn't mean that all the children have been loaded, it only means that at least some children have been loaded and are available. UsedirectChildrenCount
anddirectChildrenLoadedCount
to know if all the children have been loaded or not.childrenLoading
- type:boolean
. Boolean flag that will be true while lazy loading direct children of the current row group. UsedirectChildrenLoadedCount
anddirectChildrenCount
to know if all the children have been loaded or not.childrenSelectedCount
the number of all leaf rows in the current group that are selected.groupKeys
- type:any[]
, but usually it's actuallystring[]
. For group rows, the group keys will have all the keys starting from the topmost parent down to the current group row (key for current group row is included).groupBy
- type(keyof T)[]
. Has the same structure as groupKeys, but it will contain the fields used to group the rows.rootGroupBy
- type(keyof T)[]
. The groupBy value of the DataSource component, mapped to thegroupBy.field
groupCount
- type:number
. The count of leaf rows that the current group (in this case, the parent group) containsgroupNesting
- typenumber
. The nesting of the parent group.parents
- a list ofrowInfo
objects that are the parents of the current row.indexInParentGroups[]
- type:number[]
. See below for an example
> Italy - country - indexInParentGroups: [0]
> Rome - city - indexInParentGroups: [0,0]
- Marco - person - indexInParentGroups: [0,0,0]
- Luca - person - indexInParentGroups: [0,0,1]
- Giuseppe - person - indexInParentGroups: [0,0,2]
> USA - country - indexInParentGroups: [1]
> LA - city - indexInParentGroups: [1,0]
- Bob - person - indexInParentGroups: [1,0,2]
collapsed
- typeboolean
.selfLoaded
- type:boolean
. Useful in lazy-loading scenarios, when there is batching present. If you're not in such a scenario, the value will befalse
.
Discriminator
rowInfo.dataSourceHasGrouping === true && rowInfo.isGroupRow === true;