Row Grouping Expanded Collapsed Behaviour
Summary
- Row Groups in AdapTable can be configured to open as Expanded or Collapsed
- Users are able to set exceptions to the default for certain Row Groups
- The same functionality is available in both Table and Pivot Layouts
Developers can configure, when a Layout loads, the collapsed / expanded behaviour for Row Groups.
This is done on a per-Layout basis using the RowGroupValues property in the Base Layout object.
This behaviour is available - and identical - in both - Table Layouts and Pivot Layouts.
Note
Something very similar is available for Column Groups using the ColumnGroupValues property
Deep Dive
Understanding the RowGroupValues Object
There are 4 posible use cases for setting expanded / collapsed behaviour:
| Use Case | Default Behaviour | Provide Exceptions |
|---|---|---|
| All Groups are always exanded | always-expanded | ❌ |
| All Groups are always collapsed | always-collapsed | ❌ |
| All Groups are expanded, but exceptions listed | expanded | ✅ |
| All Groups are collapsed, but exceptions listed | collapsed | ✅ |
Consistent Behaviour
Each Layout can specify whether all Row Groups are expanded, or are all collapsed, whenever it opens.
This is done via the RowGroupDefaultBehavior property in RowGroupValues which can be set to one of 2 values:
always-expanded- every Row Group is always expanded whenever the Layout is selectedalways-collapsed- every Row Group is always collapsed whenever the Layout is selected
- This demo defines 2 Table Layouts in which Row Group behaviour is set, to show no exceptions, when the Layout opens, by configuring the
RowGroupValuesproperty:Always ExpandedhasRowGroupDefaultBehaviorset to always-expanded so all Row Groups are openAlways CollapsedhasRowGroupDefaultBehaviorset to always-collapsed so all Row Groups are closed
Listing Exceptions
Layouts also offer a more fine-grained approach to Row Group expanded and collapsed behaviour.
Developers can configure the default behaviour, while saving exceptions on a per-Row Grouped Column basis.
This is also using the RowGroupValues object, but this time 2 properties are required:
RowGroupDefaultBehavior: can be set toexpandedorcollapsedGroupKeys: containsRowGroupedColumns(array of ColIds) andExceptionGroupKeys(array of Col values)
One Row Group Column
When there is just one Column being Row-Grouped, it is straightforward to set the Exceptions.
// Set default behaviour of collapsed with 2 exceptions when grouping by Language
RowGroupValues: {
RowGroupDefaultBehavior: 'collapsed',
GroupKeys: [
{
RowGroupedColumns: ['language'],
ExceptionGroupKeys: [['TypeScript'],['JavaScript']],
}],
}- In this demo we set the
RowGroupDefaultBehaviorwith exceptions for single Row Grouped Columns: Single Grouping Collapsed Layouthas behaviour set to collapsed with exceptions for 2 Columns:Languagecolumn - exceptions for "JavaScript" and "HTML"Licensecolumn - exception for "Other"
Single Grouping Expanded Layouthas behaviour set to expanded with exception inLanguagecolumn: "JavaScript"
- In
Single Grouping Collapsed Layoutungroup byLanguageand then group byLicenseand note that the exception for "Other" is applied
Many Row Group Columns
When there is more than one Column being Row-Grouped, the Exceptions need to be set differently.
The ExceptionGroupKeys should contain a comma separated list to match the columns.
Note
- This use case deals with multi row grouped columns in one "Group" Column (i.e.
RowGroupDisplayTypeis single) - See below for setting exceptions when each Row Group is in its own Column (i.e.
RowGroupDisplayTypeis multi)
RowGroupValues: {
RowGroupDefaultBehavior: 'collapsed',
GroupKeys: [
{
RowGroupedColumns: ['language', 'license'],
ExceptionGroupKeys: [['HTML'], ['HTML', 'Other'], ['JavaScript'] ],
},
],
}- In this demo we set the
RowGroupDefaultBehaviorwith exceptions for multiple Row Grouped Columns - The
Multiple Grouping Collapsed Layoutgroups byLanguage&Licenceand behaviour set to collapsed with 3 exceptions: 'JavaScript', 'JavaScript/Other', 'HTML'
Display Type Multi
Row Group exceptions are also available when using Multi Display Types.
This is when each Row Grouped Column is displayed in its own separate Column.
The syntax for GroupKeys is the same as that used when using Multi Column Grouping.
- In this demo we have provided 2 Layouts with
RowGroupDisplayTypeof 'multi', with grouping onLanguageandLicensecolumns, and default behaviour of "collapsed":- In
Multi TypeScriptLayout we provide an exception for ["TypeScript"] (so that just that is expanded) - In
Multi HTML OtherLayout we provide an exceptions for ["HTML"] and ["HTML", "Other"] (so that just they are expanded)
- In
Pivot Layouts
The expand / collapse behaviour is exactly the same for Pivot Layouts.
You can either set a consistent behaviour or allow (and provide) exceptions to be saved.
- In this demo we have provided Pivot 2 Layouts with grouping on
LanguageandLicensecolumns:Pivot Layout Consistenthas default behaviour of "always-expanded" so every group is expandedPivot Layout Exceptionshas default behaviour of "collapsed" but with initial exceptions for JavaScript and HTML (so that they are both expanded)
- Close some groups in
Pivot Layout Consistentand then switch Layouts and back and note that the Groups are expanded again when the Layout is reloaded - Close /expand some groups in
Pivot Layout Expandedand note that these changes are re-rendered when the Layout is reloaded