All docs
V19.2
24.1
The page you are viewing does not exist in version 24.1.
23.2
The page you are viewing does not exist in version 23.2.
23.1
The page you are viewing does not exist in version 23.1.
22.2
The page you are viewing does not exist in version 22.2.
22.1
The page you are viewing does not exist in version 22.1.
21.2
The page you are viewing does not exist in version 21.2.
21.1
The page you are viewing does not exist in version 21.1.
20.2
The page you are viewing does not exist in version 20.2.
20.1
The page you are viewing does not exist in version 20.1.
19.2
19.1
18.2
18.1
17.2
Box
Row
Map
Vue
A newer version of this page is available. Switch to the current version.

jQuery DataGrid - masterDetail

Allows you to build a master-detail interface in the grid.

Type:

Object

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.

View Demo

See Also

autoExpandAll

Specifies whether detail sections appear expanded or collapsed.

Type:

Boolean

Default Value: false

NOTE
This feature is available only when all data is located locally.

component

An alias for the template property specified in React. Accepts a custom component. Refer to Using a Custom Component for more information.

enabled

Enables an end-user to expand/collapse detail sections.

Type:

Boolean

Default Value: false

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.

View Demo

See Also

render

An alias for the template property specified in React. Accepts a rendering function. Refer to Using a Rendering Function for more information.

template

Specifies a custom template for detail sections.

Type:

template

Template Data:
Name Type Description
data

Object

The master row's data object.

key any

The master row's key.

watch

Function

Allows tracking a variable and performing actions when it changes. Applies when repaintChangesOnly is true.
This function has the following parameters:

  • getter(data): Function
    A function that returns the variable that should be tracked.

  • handler(newValue): Function
    A function called when this variable changes.

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
JavaScript
$("#dataGridContainer").dxDataGrid({
    // ...
    masterDetail: {
        enabled: true,
        template: function (container, info) {
            $("<div>").dxTabPanel({ 
                // ...
                onSelectionChanged: function () {
                    $("#dataGridContainer").dxDataGrid("instance").updateDimensions();
                }
            }).appendTo(container); 
        }
    }
});
Angular
HTML
TypeScript
<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