New to Kendo UI for jQueryStart a free 30-day trial

Columns.sortable

configuration

If set to true and sorting is enabled, the user can click the column header and sort the TreeList by the column field. If set to false, sorting will be disabled for this column. By default, all columns are sortable if sorting is enabled though the sortable option.

columns.sortable

Boolean|Object

Default: true

<div id="treelist"></div>
<script>
  $("#treelist").kendoTreeList({
    columns: [
      { field: "lastName" },
      { field: "position", sortable: false }
    ],
    sortable: true,
    dataSource: {
      data: [
        { id: 1, parentId: null, lastName: "Jackson", position: "CEO" },
        { id: 2, parentId: 1, lastName: "Weber", position: "VP, Engineering" },
        { id: 3, parentId: 1, lastName: "Carr", position: "VP, Finance" }
      ]
    }
  });
</script>

A JavaScript function for comparing the values.

  • If the first argument is less than the second one, returns -1.
  • If both arguments are the same, returns 0.
  • If the first argument is greater than the second one, returns +1.
<div id="treeList"></div>
<script>
  var numbers = {
    "one"  : 1,
    "two"  : 2,
    "three": 3
  };


  $("#treeList").kendoTreeList({
    dataSource: {
      data: [
            { id: 1, parentId: null, item: "two" },
            { id: 2, parentId: 1, item: "one" },
            { id: 3, parentId: 1, item: "three" }
        ]
    },
    sortable: true,
    columns: [{
      field: "item",
      sortable: {
        compare: function(a, b) {
          return numbers[a.item] - numbers[b.item];
        }
      }
    }]
  });
</script>