ext js treesorter

Ext.tree.TreeSorter=function(tree,config){

              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.updateSorrtParent,this);

              var dsc=this.dir && this.dir.tolowerCase()=="desc";

              var p=this.property||"text";

              var sortType=this.sortType;

              var fs=this.folerSort;

               var cs=this.caseSensitive==true;

               var leafAttr=this.leafAttr ||'leaf';

                 this.sortFn=function(n1,n2){

                if(fs){

                    if(n1.attributes[leafAttr]&& !n2.attributes[leafAttr]){

                                   return 1;

                    if(!n1.attributes[leafAttr] && !n2.attributes[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());

                if(v1<v2){ return dsc? +1:-1;}

                     else(return 0;}};};

 

filterBy:function(fn,scope,startNode){

         startNode=startNode||this.tree.root;

        if(this.autoClear){this.clear();}

         var af=this.filtered,rv=this.reverse;

         var f=function(n){

           if(n=startNode){return true;}

           if(af[n.id]) {return false;}

           var m=fn.call(scope||n,n);

           if(!m||rv){

               af[n.id]=n;

                  n.ui.hide();

                 return false;}

                  return true;};

                startNode.cascade(f);

                 if(this.remove){

                    for(var id in af){

                        if(typeof id!="function"){

                                     var n=af[id];

                        if(n && n.parentNode){n.parentNode.removeChild(n);}}}}

    

 

                

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值