DevExtreme Angular - Adaptability

When adapting to a small container or screen, the TreeList 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() {
    $("#treeListContainer").dxTreeList({
        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-tree-list ... 
    [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-tree-list>
import { DxTreeListModule } from 'devextreme-angular';
// ...
export class AppComponent {
    // ...
}
@NgModule({
    imports: [
        // ...
        DxTreeListModule
    ],
    // ...
})

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 TreeList Adaptability

View 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, treeListInstance) {
    if (!treeListInstance.isAdaptiveDetailRowExpanded(key)) {
        treeListInstance.expandAdaptiveDetailRow(key);
    }
}
Angular
TypeScript
import { ..., ViewChild } from '@angular/core';
import { DxTreeListModule, DxTreeListComponent } from 'devextreme-angular';
// ...
export class AppComponent {
    @ViewChild(DxTreeListComponent) treeList: DxTreeListComponent;
    expandAdaptiveDetailRow (key) {
        if (!this.treeList.instance.isAdaptiveDetailRowExpanded(key)) {
            this.treeList.instance.expandAdaptiveDetailRow(key);
        }
    }
}
@NgModule({
    imports: [
        // ...
        DxTreeListModule
    ],
    // ...
})

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() {
    $("#treeListContainer").dxTreeList({
        // ...
        onAdaptiveDetailRowPreparing: function (e) {
            for (let formItem of e.formOptions.items) {
                if (formItem.dataField == "OrderID") {
                    formItem.isRequired = true;
                }
            }
        }
    });
});
Angular
TypeScript
HTML
import { DxTreeListModule } from 'devextreme-angular';
// ...
export class AppComponent {
    onAdaptiveDetailRowPreparing (e) {
        for (let formItem of e.formOptions.items) {
            if (formItem.dataField == "OrderID") {
                formItem.isRequired = true;
            }
        }
    }
}
@NgModule({
    imports: [
        // ...
        DxTreeListModule
    ],
    // ...
})
<dx-tree-list ...
    (onAdaptiveDetailRowPreparing)="onAdaptiveDetailRowPreparing($event)">
</dx-tree-list>
See Also