JavaScript/jQuery TreeList - Column Reordering

User Interaction

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

JavaScript
  • $(function() {
  • $("#treeListContainer").dxTreeList({
  • // ...
  • allowColumnReordering: true,
  • columns: [
  • { dataField: "CompanyName", allowReordering: false },
  • // ...
  • ]
  • });
  • });

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.

JavaScript
  • $(function() {
  • $("#treeListContainer").dxTreeList({
  • // ...
  • customizeColumns: function(columns) {
  • columns[2].visibleIndex = 1;
  • }
  • });
  • });

The visibleIndex property 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:

JavaScript
  • $("#treeListContainer").dxTreeList("columnOption", 1, "visibleIndex", 0);
See Also