sort (column: Number, method: PP.SortDirection, property: String, recursive: Boolean);
column. Number of column, values of which are to be sorted.
method. Sorting option, element of the PP.SortDirection enumeration.
property. Node property, by which the values are sorted.
recursive. Determines if children should be sorted. By default this parameter is set to true, that is, sorting will be applied.
The sort method sorts tree elements by column.
To execute this method, sorting option must be enabled: that is, the TreeList.EnableSortColumns property must be set to true.
Nodes are sorted after clicking the column heading. The icon appears for descending sorting, and the icon is shown for ascending sorting.
To execute this example, the page must contain the TreeList component named treeListSett (see Example of Creating the TreeList Component). Add a button clicking which sorts tree values in the first column in descending order:
var but1 = new PP.Ui.Button( { ParentNode: document.getElementById("but1"), Content: "Sort", Click: function () { treeListSett.setEnableSortColumns(true);//enable sorting option by columns treeListSett.collapseAll();//Collapse all tree nodes treeListSett.sort(0, PP.Ui.TreeListSort.desc, 'Checked', true); //descending sorting by the first column, value of the TreeNode.Checked property is taking into account:at the beginning there are nodes with checkbox selected; sorting using recursion: processes also in collapsed child nodes //Shoe sorting parameters to the console console.log("Sorted column: " + treeListSett.getSortColumn() + "; Sorting method: " + treeListSett.getSortMethod() + "; Property: " + treeListSett.getSortProperty() + ";Using recursion: " + treeListSett.getSortRecursive()); } })
After executing the example clicking the Sort button enables sorting by column; elements of the first column are sorted in descending order, using recursion, and taking into account the TreeNode.Checked property.
Sorting options are displayed to the console:
Sorted column: 0; Sorting method: 2; Property: Checked; Recursive: true
See also: