masterDetail
Allows you to build a master-detail interface in the grid.
In DataGrid, a master-detail interface supplies a usual data row with an expandable section that contains the details on this data row. In that case, the data row is called "master row", while the section is called "detail section".
To enable the master-detail interface, assign true to the masterDetail.enabled option. After that, specify the template for detail sections using the masterDetail.template option. Templates allow you to place virtually anything into the detail sections. For example, you can display another DataGrid or any other UI widget there. For more information on specifying the template for the detail sections, see the template option description.
See Also
component
An alias for the template option specified in React. Accepts a custom component. Refer to Using a Custom Component for more information.
enabled
If you set this option to true, each grid row will be supplied with an arrow that allows an end-user to expand/collapse the detail section of this row.
If the masterDetail.enabled option is false, the expanding arrows are missing. It makes detail sections unreachable for an end-user.
Setting this option to false is recommended if you need a custom logic of expanding/collapsing the detail sections. When implementing this logic, you can use specific API methods. To check whether the detail section is expanded or collapsed, use the isRowExpanded(key) method. To expand or collapse a specific detail section, call the expandRow(key) or collapseRow(key) method respectively.
See Also
render
An alias for the template option specified in React. Accepts a rendering function. Refer to Using a Rendering Function for more information.
template
Name | Type | Description |
---|---|---|
data |
The master row's data object. |
|
key | any |
The master row's key. |
watch |
Allows tracking a variable and performing actions when it changes. Applies when repaintChangesOnly is true.
|
You should call the updateDimensions() method each time the size of the detail section's content changes to make the table layout automatically adapt its size. In the following code, the TabPanel in the detail section contains views that can have different heights. The updateDimensions method is called in the onSelectionChanged handler to update the table layout when another view is selected.
jQuery
$("#dataGridContainer").dxDataGrid({ // ... masterDetail: { enabled: true, template: function (container, info) { $("<div>").dxTabPanel({ // ... onSelectionChanged: function () { $("#dataGridContainer").dxDataGrid("instance").updateDimensions(); } }).appendTo(container); } } });
Angular
<dx-data-grid ... [masterDetail]="{ enabled: true, template: 'detail' }"> <div *dxTemplate="let info of 'detail'"> <dx-tab-panel ... (onSelectionChanged)="onSelectionChanged()"> </dx-tab-panel> </div> </dx-data-grid>
import { DxDataGridModule, DxDataGridComponent, DxTabPanelModule } from "devextreme-angular"; // ... export class AppComponent { @ViewChild(DxDataGridComponent, { static: false }) dataGrid: DxDataGridComponent // Prior to Angular 8 // @ViewChild(DxDataGridComponent) dataGrid: DxDataGridComponent onSelectionChanged () { this.dataGrid.instance.updateDimensions(); } } @NgModule({ imports: [ // ... DxDataGridModule, DxTabPanelModule ], // ... })
See Also
If you have technical questions, please create a support ticket in the DevExpress Support Center.
We appreciate your feedback.