Extension for Tree that makes nodes sortable.
Tree.Sortable[config]
[config]
Object
optional
Configuration options.
[sortComparator]
Function
optional
Default comparator function to use when sorting a node's children if the node itself doesn't have a custom comparator function. If not specified, insertion order will be used by default.
[sortReverse=false]
Boolean
optional
If true, node children will be
sorted in reverse (descending) order by default. Otherwise they'll be sorted
in ascending order.
_comparea
b
Compares value a to value b for sorting purposes.
Values are assumed to be the result of calling a sortComparator function.
a
Mixed
First value to compare.
b
Mixed
Second value to compare.
-1 if a should come before b, 0 if they're
equivalent, 1 if a should come after b.
_compareReversea
b
Compares value a to value b for sorting purposes, but sorts them in reverse (descending) order.
Values are assumed to be the result of calling a sortComparator function.
a
Mixed
First value to compare.
b
Mixed
Second value to compare.
-1 if a should come before b, 0 if they're
equivalent, 1 if a should come after b.
_getDefaultNodeIndexparent
node
[options]
Overrides Tree#_getDefaultNodeIndex() to provide insertion-time sorting
for nodes inserted without an explicit index.
Index at which node should be inserted into parent's
children array.
_getSortComparatornode
[options]
Returns a sort comparator function derived from the given node and
options, and bound to the correct thisObj based on where it was found.
Properly bound sort comparator function.
_sorta
b
comparator
[reverse=false]
Array sort function used by sortNode() to re-sort a node's children.
-1 if a is less than b, 0 if equal, 1 if greater.
sort[options]
Sorts the children of every node in this tree.
A sort event will be fired for each node whose children are sorted, which
can get very noisy. If this is a large tree, you may want to set the
silent option to true to suppress these events.
[options]
Object
optional
Options.
[silent]
Boolean
optional
If true, no sort events will be
fired.
[sortComparator]
Function
optional
Custom comparator function to use. If specified, this will become the new comparator function for each node, overwriting any previous comparator function that was set for the node.
[sortReverse]
Boolean
optional
If true, children will be
sorted in reverse (descending) order. Otherwise they'll be sorted in
ascending order. This will become each node's new sort order,
overwriting any previous sort order that was set for the node.
[src]
String
optional
Source of the sort operation. Will be
passed along to the sort event facade.
sortComparatornode
Default comparator function to use when sorting a node's children if the node itself doesn't have a custom comparator function.
If not specified, insertion order will be used by default.
node
Tree.Node
Node being sorted.
sortNodenode
[options]
Sorts the children of the specified node.
By default, only the node's direct children are sorted. To sort all nodes in
the hierarchy (children, children's children, etc.), set the deep option
to true. If this is a very deep hierarchy, you may also want to set
silent to true to avoid generating a flood of sort events.
node
Tree.Node
Node whose children should be sorted.
[options]
Object
optional
Options.
[deep=false]
Boolean
optional
If true, all of this node's
children (and their children, and so on) will be traversed and
re-sorted as well.
[silent]
Boolean
optional
If true, no sort event will be
fired.
[sortComparator]
Function
optional
Custom comparator function to use. If specified, this will become the node's new comparator function, overwriting any previous comparator function that was set for the node.
[sortReverse]
Boolean
optional
If true, children will be
sorted in reverse (descending) order. Otherwise they'll be sorted in
ascending order. This will become the node's new sort order,
overwriting any previous sort order that was set for the node.
[src]
String
optional
Source of the sort operation. Will be
passed along to the sort event facade.
sortReverseIf true, node children will be sorted in reverse (descending) order by
default. Otherwise they'll be sorted in ascending order.
Default: false