X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/6e39d509471fe9b4e2660e0d1631b350d0c66f40..2e847cf21b8ab9d15fa167b315ca5b2fa92638fc:/docs/source/TreeSorter.html diff --git a/docs/source/TreeSorter.html b/docs/source/TreeSorter.html index fb13dd77..e88db76b 100644 --- a/docs/source/TreeSorter.html +++ b/docs/source/TreeSorter.html @@ -8,7 +8,7 @@
/** * @class Ext.tree.TreeSorter - * Provides sorting of nodes in a {@link Ext.tree.TreePanel}. The TreeSorter automatically monitors events on the + * Provides sorting of nodes in a {@link Ext.tree.TreePanel}. The TreeSorter automatically monitors events on the * associated TreePanel that might affect the tree's sort order (beforechildrenrendered, append, insert and textchange). * Example usage:
*

@@ -29,33 +29,33 @@ Ext.tree.TreeSorter = function(tree, config){
     
/** * @cfg {Boolean} folderSort True to sort leaf nodes under non-leaf nodes (defaults to false) */ -
/** - * @cfg {String} property The named attribute on the node to sort by (defaults to "text"). Note that this +
/** + * @cfg {String} property The named attribute on the node to sort by (defaults to "text"). Note that this * property is only used if no {@link #sortType} function is specified, otherwise it is ignored. */ -
/** +
/** * @cfg {String} dir The direction to sort ("asc" or "desc," case-insensitive, defaults to "asc") */ -
/** +
/** * @cfg {String} leafAttr The attribute used to determine leaf nodes when {@link #folderSort} = true (defaults to "leaf") */ -
/** +
/** * @cfg {Boolean} caseSensitive true for case-sensitive sort (defaults to false) */ -
/** +
/** * @cfg {Function} sortType A custom "casting" function used to convert node values before sorting. The function * will be called with a single parameter (the {@link Ext.tree.TreeNode} being evaluated) and is expected to return * the node's sort value cast to the specific data type required for sorting. This could be used, for example, when - * a node's text (or other attribute) should be sorted as a date or numeric value. See the class description for + * a node's text (or other attribute) should be sorted as a date or numeric value. See the class description for * example usage. Note that if a sortType is specified, any {@link #property} config will be ignored. */ - + Ext.apply(this, config); tree.on("beforechildrenrendered", this.doSort, this); tree.on("append", this.updateSort, this); tree.on("insert", this.updateSort, this); tree.on("textchange", this.updateSortParent, this); - + var dsc = this.dir && this.dir.toLowerCase() == "desc"; var p = this.property || "text"; var sortType = this.sortType; @@ -72,14 +72,14 @@ Ext.tree.TreeSorter = function(tree, config){ return -1; } } - var v1 = sortType ? sortType(n1.attributes[p]) : (cs ? n1.attributes[p] : n1.attributes[p].toUpperCase()); - var v2 = sortType ? sortType(n2.attributes[p]) : (cs ? n2.attributes[p] : n2.attributes[p].toUpperCase()); - if(v1 < v2){ - return dsc ? +1 : -1; - }else if(v1 > v2){ - return dsc ? -1 : +1; + var v1 = sortType ? sortType(n1) : (cs ? n1.attributes[p] : n1.attributes[p].toUpperCase()); + var v2 = sortType ? sortType(n2) : (cs ? n2.attributes[p] : n2.attributes[p].toUpperCase()); + if(v1 < v2){ + return dsc ? +1 : -1; + }else if(v1 > v2){ + return dsc ? -1 : +1; }else{ - return 0; + return 0; } }; }; @@ -88,20 +88,20 @@ Ext.tree.TreeSorter.prototype = { doSort : function(node){ node.sort(this.sortFn); }, - + compareNodes : function(n1, n2){ return (n1.text.toUpperCase() > n2.text.toUpperCase() ? 1 : -1); }, - + updateSort : function(tree, node){ if(node.childrenRendered){ this.doSort.defer(1, this, [node]); } }, - + updateSortParent : function(node){ - var p = node.parentNode; - if(p && p.childrenRendered){ + var p = node.parentNode; + if(p && p.childrenRendered){ this.doSort.defer(1, this, [p]); } }