All docs
V19.1
24.2 (CTP)
The page you are viewing does not exist in version 24.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
A newer version of this page is available. Switch to the current version.

DevExtreme jQuery/JS - Adaptability

When adapting to a small container or screen, the DataGrid can hide columns. To enable this feature, set the columnHidingEnabled to true. Columns have hiding priorities - zero-based indexes that determine the order in which they are hidden. These indexes ascend from right to left by default, which means that the rightmost column is always at risk of being hidden. Use the hidingPriority option to specify a custom hiding priority and cancel the default priorities.

jQuery
JavaScript
$(function() {
    $("#dataGridContainer").dxDataGrid({
        columnHidingEnabled: true,
        columns: [{
            // ...
            hidingPriority: 2 // a valuable column
        }, {
            // ...
            hidingPriority: 1 // a not-so-valuable column 
        }, {
            // ...
            hidingPriority: 0 // a first-to-hide column
        }]
    });
});
Angular
HTML
TypeScript
<dx-data-grid ... 
    [columnHidingEnabled]="true">
    <dxi-column [hidingPriority]="2" ... ></dxi-column> <!-- a valuable column -->
    <dxi-column [hidingPriority]="1" ... ></dxi-column> <!-- a not-so-valuable column -->
    <dxi-column [hidingPriority]="0" ... ></dxi-column> <!-- a first-to-hide column -->
</dx-data-grid>
import { DxDataGridModule } from "devextreme-angular";
// ...
export class AppComponent {
    // ...
}
@NgModule({
    imports: [
        // ...
        DxDataGridModule
    ],
    // ...
})
NOTE

The table layout does not automatically adapt to changes made in the widget's container at runtime. Therefore, if you enable a user to resize the container, call the updateDimensions() method after each resizing to render the DataGrid in the new size.

jQuery
JavaScript
$("#dataGridContainer").dxDataGrid("updateDimensions");
Angular
TypeScript
import { ..., ViewChild } from "@angular/core";
import { DxDataGridModule, DxDataGridComponent } from "devextreme-angular";
// ...
export class AppComponent {
    @ViewChild(DxDataGridComponent, { static: false }) grid: DxDataGridComponent;
    // Prior to Angular 8
    // @ViewChild(DxDataGridComponent) grid: DxDataGridComponent;
    renderDataGrid () {
        this.grid.instance.updateDimensions();
    };
}
@NgModule({
    imports: [
        // ...
        DxDataGridModule
    ],
    // ...
})

Data from hidden columns is still available in adaptive detail rows. A user can expand or collapse these rows by clicking the ellipsis buttons in the adaptive column.

DevExtreme HTML5 JavaScript jQuery Knockout Angular DataGrid Adaptability

Adaptability Demo Hiding Priority Demo

You can expand or collapse adaptive detail rows programmatically by calling the expandAdaptiveDetailRow(key) or collapseAdaptiveDetailRow() method. Note that adaptive detail rows cannot be expanded simultaneously, therefore, calling the expandAdaptiveDetailRow(key) method collapses the previously expanded row. To check whether a specific row is expanded, call the isAdaptiveDetailRowExpanded(key) method.

jQuery
JavaScript
var expandAdaptiveDetailRow = function (key, dataGridInstance) {
    if (!dataGridInstance.isAdaptiveDetailRowExpanded(key)) {
        dataGridInstance.expandAdaptiveDetailRow(key);
    }
}
Angular
TypeScript
import { ..., ViewChild } from "@angular/core";
import { DxDataGridModule, DxDataGridComponent } from "devextreme-angular";
// ...
export class AppComponent {
    @ViewChild(DxDataGridComponent, { static: false }) dataGrid: DxDataGridComponent;
    // Prior to Angular 8
    // @ViewChild(DxDataGridComponent) dataGrid: DxDataGridComponent;
    expandAdaptiveDetailRow (key) {
        if (!this.dataGrid.instance.isAdaptiveDetailRowExpanded(key)) {
            this.dataGrid.instance.expandAdaptiveDetailRow(key);
        }
    }
}
@NgModule({
    imports: [
        // ...
        DxDataGridModule
    ],
    // ...
})

All adaptive detail rows contain the DevExtreme Form widget, so you can customize a row by changing the options of this widget. To access them, implement the onAdaptiveDetailRowPreparing event handler. For example, the following code marks the form item whose data field is "OrderID" as required:

jQuery
JavaScript
$(function() {
    $("#dataGridContainer").dxDataGrid({
        // ...
        onAdaptiveDetailRowPreparing: function (e) {
            for (let formItem of e.formOptions.items) {
                if (formItem.dataField == "OrderID") {
                    formItem.isRequired = true;
                }
            }
        }
    });
});
Angular
TypeScript
HTML
import { DxDataGridModule } from "devextreme-angular";
// ...
export class AppComponent {
    onAdaptiveDetailRowPreparing (e) {
        for (let formItem of e.formOptions.items) {
            if (formItem.dataField == "OrderID") {
                formItem.isRequired = true;
            }
        }
    }
}
@NgModule({
    imports: [
        // ...
        DxDataGridModule
    ],
    // ...
})
<dx-data-grid ...
    (onAdaptiveDetailRowPreparing)="onAdaptiveDetailRowPreparing($event)">
</dx-data-grid>
See Also