Master Detail Grids

View as Markdown

Summary

  • AdapTable fully supports the Master / Detail mode provided by AG Grid
  • It provides a dedicated Plugin which extends the functionality on offer

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

Terminal
npm install @adaptabletools/adaptable-plugin-master-detail-aggrid

Caution

  • If using CommonJS, then install @adaptabletools/adaptable-plugin-master-detail-aggrid-cjs instead
  • Make sure also to include your License Key in the DetailOptions grid 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

Master Detail
Fork
  • 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 Stars column

Expand to see how the Master Detail Grid was configured

Try It Out
  • Create a Format Column in one Details Grid and see it applied in the other 2
Loading demo…

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

Master Detail - Detail Init
Fork
  • This demo illustrates how to use onDetailInit to 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 Language is "JavaScript" or "TypeScript"

Expand to see how onDetailInit was used

Loading demo…

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[] | undefined
Detail rows to include under each master row when exporting a master–detail grid

Find Out More

See Configuring Export for the full Export Options available

Master Detail — Export
Fork
  • Master rows list programming languages; expand a row to load frameworks for that language in the detail grid
  • getDetailRows exports those frameworks under each master row when you run Current Layout to Excel or CSV
Try It Out
  • Export Current Layout to Excel and open the file — each language row is followed by its framework detail rows
Loading demo…

Master Detail Plugin Options

Plugin Options used when creating a Master / Detail grid - passed into the plugin as the only argument.

PropertyTypeDescription
detailAdaptableOptionsAdaptableOptionsAdaptableOptions used in Detail Grids; all share same behaviour & State
onDetailInit(context:DetailInitContext) => voidFunction 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).