SortMethod: Function
The SortMethod property sets function intended for column elements sorting.
Use JSON or the setSortMethod method to set the property value, and the getSortMethod method to get the property value.
To execute the example, the page must contain the TreeList component named «treeList» (see Example of Creating the TreeList Component). Set a new sorting method for the tree first column which will sort elements by the second character of the contents:
// Get the first tree column var column = treeList.getColumns().getItem(0); // Set a new sorting method column.setSortMethod(function (nodeA, nodeB, params) { if (nodeA.Text.charAt(1) >= nodeB.Text.charAt(1)) { return true; } else { return false; } });
Sort elements on clicking the first column heading. As a result, elements are sorted by the second character of its contents:
See also: