X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/b37ceabb82336ee82757cd32efe353cfab8ec267..f5240829880f87e0cf581c6a296e436fdef0ef80:/examples/ux/treegrid/TreeGridSorter.js diff --git a/examples/ux/treegrid/TreeGridSorter.js b/examples/ux/treegrid/TreeGridSorter.js index 5a2f95be..ae93e127 100644 --- a/examples/ux/treegrid/TreeGridSorter.js +++ b/examples/ux/treegrid/TreeGridSorter.js @@ -1,5 +1,5 @@ /*! - * Ext JS Library 3.2.2 + * Ext JS Library 3.3.0 * Copyright(c) 2006-2010 Ext JS, Inc. * licensing@extjs.com * http://www.extjs.com/license @@ -54,30 +54,34 @@ Ext.ux.tree.TreeGridSorter = Ext.extend(Ext.tree.TreeSorter, { tree.on('headerclick', this.onHeaderClick, this); tree.ddAppendOnly = true; - me = this; + var me = this; this.defaultSortFn = function(n1, n2){ - var dsc = me.dir && me.dir.toLowerCase() == 'desc'; - var p = me.property || 'text'; - var sortType = me.sortType; - var fs = me.folderSort; - var cs = me.caseSensitive === true; - var leafAttr = me.leafAttr || 'leaf'; + var desc = me.dir && me.dir.toLowerCase() == 'desc', + prop = me.property || 'text', + sortType = me.sortType, + caseSensitive = me.caseSensitive === true, + leafAttr = me.leafAttr || 'leaf', + attr1 = n1.attributes, + attr2 = n2.attributes; - if(fs){ - if(n1.attributes[leafAttr] && !n2.attributes[leafAttr]){ + if(me.folderSort){ + if(attr1[leafAttr] && !attr2[leafAttr]){ return 1; } - if(!n1.attributes[leafAttr] && n2.attributes[leafAttr]){ + if(!attr1[leafAttr] && attr2[leafAttr]){ return -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()); + var prop1 = attr1[prop], + prop2 = attr2[prop], + v1 = sortType ? sortType(prop1) : (caseSensitive ? prop1 : prop1.toUpperCase()); + v2 = sortType ? sortType(prop2) : (caseSensitive ? prop2 : prop2.toUpperCase()); + if(v1 < v2){ - return dsc ? +1 : -1; + return desc ? +1 : -1; }else if(v1 > v2){ - return dsc ? -1 : +1; + return desc ? -1 : +1; }else{ return 0; } @@ -126,8 +130,8 @@ Ext.ux.tree.TreeGridSorter = Ext.extend(Ext.tree.TreeSorter, { // private updateSortIcon : function(col, dir){ - var sc = this.sortClasses; - var hds = this.tree.innerHd.select('td').removeClass(sc); + var sc = this.sortClasses, + hds = this.tree.innerHd.select('td').removeClass(sc); hds.item(col).addClass(sc[dir == 'desc' ? 1 : 0]); } }); \ No newline at end of file