Master Detail with Custom Row Detail Contents
The Infinite Table Angular DataGrid allows you to render any template as row details - the
rowDetailRenderer function returns an ng-template of your component (a TemplateRef, read with viewChild), which gets the master row as its context (let-rowInfo), or a component (renderComponent(MyRowDetail)).You can render a DataGrid directly or you can nest the DataGrid at any level of nesting inside the row details.
Or you can simply choose to render anything else - no DataGrid required.
Rendering a detail DataGrid#
Your row detail content can include another Infinite Table DataGrid.
The DataGrid you're rendering inside the row detail doesn't need to be the root of the template the
rowDetailRenderer function returns - it can be nested inside other elements of that template.#
Master detail with custom content & DataGrid
In this example, the row detail contains custom content, along with another Infinite Table DataGrid. You can nest a child DataGrid inside the row details at any level of nesting.
loading demo…
You'll probably want to configure the height of the row detail content. Use the
rowDetailHeight prop to do that.Rendering a chart component as row detail#
#
Retrieving cell selection value by mapping over them
loading demo…
In the above example, please note that on every render (after the detail component is mounted), we pass the same
dataSource, groupBy and aggregationReducers props to the <DataSource /> component. The references for all those objects are stable. We don't want to pass new references on every render, as that would cause the <DataSource /> to reload and reprocess the data.Multiple levels of nesting#
The master-detail configuration for the DataGrid can contain any level of nesting.
The example below shows 3 levels of nesting - so a master DataGrid, a detail DataGrid and another third-level detail with custom content.
#
Master detail with 3 levels of nesting
In this example, we have 3 levels of nesting:
- The master DataGrid shows cities/countries
- The first level of detail shows developers in each city
- The second level of detail shows custom data about each developer
loading demo…
Understanding the lifecycle of the row detail component#
You have to keep in mind that the content you render in the row detail can be mounted and unmounted multiple times. Whenever the user expands the row detail, it gets mounted and rendered, but then it will be unmounted when the user scrolls the content out of view. This can happen very often.
Also note that the row detail element is recycled - it can be reused for different rows. When that happens, the content you render (the views of your template, or your component) is destroyed and created again for the new master row, so a component never shows the details of two different rows.
In practice this means that it's best if your row detail content is using controlled state and avoids using local state.