DevExtreme Vue - Column Reordering

User Interaction

Set the allowColumnReordering option to true to allow a user to reorder columns. If a specific column should not be moved, set its allowReordering option to false.

jQuery
JavaScript
$(function() {
    $("#treeListContainer").dxTreeList({
        // ...
        allowColumnReordering: true,
        columns: [
            { dataField: "CompanyName", allowReordering: false },
            // ...
        ]
    });
});
Angular
HTML
TypeScript
<dx-tree-list ...
    [allowColumnReordering]="true">
    <dxi-column dataField="CompanyName" [allowReordering]="false"></dxi-column>
</dx-tree-list>
import { DxTreeListModule } from "devextreme-angular";
// ...
export class AppComponent {
    // ...
}
@NgModule({
    imports: [
        // ...
        DxTreeListModule
    ],
    // ...
})

View Demo

API

The columns array determines columns' order. You can reorder columns by moving their objects within the array or by changing the column's visibleIndex if you prefer to configure columns using the customizeColumns function.

jQuery
JavaScript
$(function() {
    $("#treeListContainer").dxTreeList({
        // ...
        customizeColumns: function(columns) {
            column[2].visibleIndex = 1;
        }
    });
});
Angular
TypeScript
HTML
import { DxTreeListModule } from "devextreme-angular";
// ...
export class AppComponent {
    customizeColumns (columns) {
        column[2].visibleIndex = 1;
    }
}
@NgModule({
    imports: [
        // ...
        DxTreeListModule
    ],
    // ...
})
<dx-tree-list ...
    [customizeColumns]="customizeColumns">
</dx-tree-list>

The visibleIndex option can also be changed at runtime to reorder columns regardless of the way you configured them. For this, call the columnOption(id, optionName, optionValue) method. The following code swaps the second and first column:

jQuery
JavaScript
$("#treeListContainer").dxTreeList("columnOption", 1, "visibleIndex", 0);
Angular
TypeScript
import { ..., ViewChild } from "@angular/core";
import { DxTreeListModule, DxTreeListComponent } from "devextreme-angular";
// ...
export class AppComponent {
    @ViewChild(DxTreeListComponent) treeList: DxTreeListComponent;
    swapColumns () {
        this.treeList.instance.columnOption(1, "visibleIndex", 0);
    }
}
@NgModule({
    imports: [
        // ...
        DxTreeListModule
    ],
    // ...
})
See Also