Master Detail Grids
Summary
One of the most powerful features in AG Grid are Master Detail Grids.
These are grids where each row in the Master Grid can be expanded to display a Details grid.
AdapTable fully supports (and extends) AG Grid Master Detail grids.
It does so via a dedicated Plugin which provides extra features.
Primarily it enables all Detail Grids to share common AdapTable objects (e.g. Reports or Format Columns).
Installing Master Detail Plugin
Caution
- If using CommonJS, then install
@adaptabletools/adaptable-plugin-master-detail-aggrid-cjsinstead - Make sure also to include your License Key in the
DetailOptionsgrid you provide
Unlike with Row Grouping, the Details Grid is a totally separate, fully configurable AdapTable instance.
Note
Each Details Grid contains its own set of columns and own unique data
This allows you essentially to provide 2 definitions:
- the main Master Grid which provides the top level of rows
- the Details Grid which will appear when a Master row is expanded
Deep Dive
Providing Details Grid Definition
It is possible to create a second Master / Detail grid as the child of an initial Master / Details grid.
Caution
Only one level of nesting Master / Details grids is possible
Note
When the Master Grid is row grouped, a Layout with RowGroupDefaultBehavior: 'always-expanded' (see Expanding Row Groups) and gridApi.expandAllRowGroups() expand the Row Groups only, not the Master rows
- This demo illustrates how to use Master Detail Grids in AdapTable
- The Master and Detail grids have different AdapTable configurations
- However each Detail Grids shares the same Column Formatting on the
GitHub Starscolumn
Expand to see how the Master Detail Grid was configured
- Create a Format Column in one Details Grid and see it applied in the other 2
Initialising the Details Grid
AdapTable provides an onDetailInit property.
This contains a function that is invoked when a Details Grid is initialised.
Hint
You can use this property to provide bespoke configuration for the Details Grid at run-time
Deep Dive
onDetailInit property
- This demo illustrates how to use
onDetailInitto configure the Detail Grids in Master Detail Grids - The function calls the AdapTable API to close the Tool Panel (SideBar) in the Details Grid when it opens - but only if the
Languageis "JavaScript" or "TypeScript"
Expand to see how onDetailInit was used
Exporting Detail Rows
By default, exporting a master–detail grid includes master rows only.
Detail grids are separate AdapTable instances and are not merged into the file automatically.
To export nested rows for each expanded master row, set getDetailRows in Export Options.
getDetailRows
(context: GetDetailRowsContext) => CsvDetailRow[] | ExcelDetailRow[] | undefinedFind Out More
See Configuring Export for the full Export Options available
- Master rows list programming languages; expand a row to load frameworks for that language in the detail grid
getDetailRowsexports those frameworks under each master row when you run Current Layout to Excel or CSV
- Export Current Layout to Excel and open the file — each language row is followed by its framework detail rows
Master Detail Plugin Options
Plugin Options used when creating a Master / Detail grid - passed into the plugin as the only argument.
| Property | Type | Description |
|---|---|---|
| detailAdaptableOptions | AdaptableOptions | AdaptableOptions used in Detail Grids; all share same behaviour & State |
| onDetailInit | (context:DetailInitContext) => void | Function called when a Detail Grid is initialised, receives context including Adaptable Api |
FAQ
Can I export master and detail rows in one file?
Yes. Without getDetailRows, exports include master rows only. Implement getDetailRows in Export Options so detail data is nested under each master row in Excel or CSV exports (see Exporting Detail Rows).
Can I export a detail grid on its own?
Yes — each detail grid is its own AdapTable instance and can be exported separately via the Export API if you obtain its Adaptable API (for example from onDetailInit).