Roo/bootstrap/Table.js
authorEdward <edward@roojs.com>
Thu, 10 Jul 2014 05:33:16 +0000 (13:33 +0800)
committerEdward <edward@roojs.com>
Thu, 10 Jul 2014 05:33:16 +0000 (13:33 +0800)
roojs-bootstrap.js
roojs-bootstrap-debug.js

Roo/bootstrap/Table.js
roojs-bootstrap-debug.js
roojs-bootstrap.js

index c2c80e4..ce7cc23 100644 (file)
@@ -291,10 +291,11 @@ Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component,  {
             
             if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'ASC'){
                 e.addClass('glyphicon', 'glyphicon-arrow-up');
-                return;
             }
             
-            e.addClass('glyphicon', 'glyphicon-arrow-down');
+            if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'DESC'){
+                e.addClass('glyphicon', 'glyphicon-arrow-down');
+            }
         });
         
         var tbody = this.el.select('tbody', true).first();
index 023462e..bbdd830 100644 (file)
@@ -3054,10 +3054,11 @@ Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component,  {
             
             if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'ASC'){
                 e.addClass('glyphicon', 'glyphicon-arrow-up');
-                return;
             }
             
-            e.addClass('glyphicon', 'glyphicon-arrow-down');
+            if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'DESC'){
+                e.addClass('glyphicon', 'glyphicon-arrow-down');
+            }
         });
         
         var tbody = this.el.select('tbody', true).first();
index b245d6c..7e7164d 100644 (file)
@@ -80,8 +80,7 @@ Roo.bootstrap.Slider=function(A){Roo.bootstrap.Slider.superclass.constructor.cal
 Roo.bootstrap.Table=function(A){Roo.bootstrap.Table.superclass.constructor.call(this,A);if(this.sm){this.selModel=Roo.factory(this.sm,Roo.bootstrap.Table);this.sm=this.selModel;this.sm.xmodule=this.xmodule||false;}if(this.cm&&typeof(this.cm.config)=='undefined'){this.colModel=new Roo.bootstrap.Table.ColumnModel(this.cm);this.cm=this.colModel;this.cm.xmodule=this.xmodule||false;}if(this.store){this.store=Roo.factory(this.store,Roo.data);this.ds=this.store;this.ds.xmodule=this.xmodule||false;}};Roo.extend(Roo.bootstrap.Table,Roo.bootstrap.Component,{cls:false,align:false,bgcolor:false,border:false,cellpadding:false,cellspacing:false,frame:false,rules:false,sortable:false,summary:false,width:false,striped:false,bordered:false,hover:false,condensed:false,responsive:false,sm:false,cm:false,store:false,getAutoCreate:function(){var A=Roo.apply({},Roo.bootstrap.Table.superclass.getAutoCreate.call(this));A={tag:'table',cls:'table',cn:[]};if(this.striped){A.cls+=' table-striped';}if(this.hover){A.cls+=' table-hover';}if(this.bordered){A.cls+=' table-bordered';}if(this.condensed){A.cls+=' table-condensed';}if(this.responsive){A.cls+=' table-responsive';}if(this.cls){A.cls+=' '+this.cls;}if(this.align){A.align=this.align;}if(this.bgcolor){A.bgcolor=this.bgcolor;}if(this.border){A.border=this.border;}if(this.cellpadding){A.cellpadding=this.cellpadding;}if(this.cellspacing){A.cellspacing=this.cellspacing;}if(this.frame){A.frame=this.frame;}if(this.rules){A.rules=this.rules;}if(this.sortable){A.sortable=this.sortable;}if(this.summary){A.summary=this.summary;}if(this.width){A.width=this.width;}if(this.store||this.cm){A.cn.push(this.renderHeader());A.cn.push(this.renderBody());A.cn.push(this.renderFooter());A.cls+=' TableGrid';}return A;},initEvents:function(){if(!this.store||!this.cm){return;}
 Roo.log('initEvents with ds!!!!');var A=this;Roo.each(this.el.select('thead th.sortable',true).elements,function(e){e.on('click',A.sort,A);});this.store.on('load',this.onLoad,this);this.store.on('beforeload',this.onBeforeLoad,this);this.store.load();},sort:function(e,el){var A=Roo.get(el)if(!A.hasClass('sortable')){return;}var sort=A.attr('sort');var B='ASC';if(A.hasClass('glyphicon-arrow-up')){B='DESC';}
 this.store.sortInfo={field:sort,direction:B};this.store.load();},renderHeader:function(){var A={tag:'thead',cn:[]};var cm=this.cm;for(var i=0,B=cm.getColumnCount();i<B;i++){var C=cm.config[i];var c={tag:'th',html:cm.getColumnHeader(i)};if(typeof(C.dataIndex)!='undefined'){c.sort=C.dataIndex;}if(typeof(C.sortable)!='undefined'&&C.sortable){c.cls='sortable';}
-A.cn.push(c)}return A;},renderBody:function(){var A={tag:'tbody',cn:[]};return A;},renderFooter:function(){var A={tag:'tfoot',cn:[]};return A;},onLoad:function(){Roo.log('ds onload');var A=this;var cm=this.cm;Roo.each(this.el.select('thead th.sortable',true).elements,function(e){e.removeClass(['glyphicon','glyphicon-arrow-up','glyphicon-arrow-down']);var D=e.attr('')if(e.hasClass('sortable')&&e.attr('sort')==A.store.sortInfo.field&&A.store.sortInfo.direction.toUpperCase()=='ASC'){e.addClass('glyphicon','glyphicon-arrow-up');return;}
-e.addClass('glyphicon','glyphicon-arrow-down');});var B=this.el.select('tbody',true).first();var C=[];if(this.store.getCount()>0){this.store.data.each(function(d){var D={tag:'tr',cn:[]};for(var i=0,E=cm.getColumnCount();i<E;i++){var F=cm.getRenderer(i);var G=cm.config[i];var H='';var id=Roo.id();if(typeof(F)!=='undefined'){H=F(d.data[cm.getDataIndex(i)],false,d);}if(typeof(H)==='object'){C.push({id:id,cfg:H})}var td={tag:'td',id:id,html:(typeof(H)==='object')?'':H};if(typeof(G.width)!='undefined'){td.width=G.width;}
+A.cn.push(c)}return A;},renderBody:function(){var A={tag:'tbody',cn:[]};return A;},renderFooter:function(){var A={tag:'tfoot',cn:[]};return A;},onLoad:function(){Roo.log('ds onload');var A=this;var cm=this.cm;Roo.each(this.el.select('thead th.sortable',true).elements,function(e){e.removeClass(['glyphicon','glyphicon-arrow-up','glyphicon-arrow-down']);var D=e.attr('')if(e.hasClass('sortable')&&e.attr('sort')==A.store.sortInfo.field&&A.store.sortInfo.direction.toUpperCase()=='ASC'){e.addClass('glyphicon','glyphicon-arrow-up');}if(e.hasClass('sortable')&&e.attr('sort')==A.store.sortInfo.field&&A.store.sortInfo.direction.toUpperCase()=='DESC'){e.addClass('glyphicon','glyphicon-arrow-down');}});var B=this.el.select('tbody',true).first();var C=[];if(this.store.getCount()>0){this.store.data.each(function(d){var D={tag:'tr',cn:[]};for(var i=0,E=cm.getColumnCount();i<E;i++){var F=cm.getRenderer(i);var G=cm.config[i];var H='';var id=Roo.id();if(typeof(F)!=='undefined'){H=F(d.data[cm.getDataIndex(i)],false,d);}if(typeof(H)==='object'){C.push({id:id,cfg:H})}var td={tag:'td',id:id,html:(typeof(H)==='object')?'':H};if(typeof(G.width)!='undefined'){td.width=G.width;}
 D.cn.push(td);}
 B.createChild(D);});}if(C.length){var A=this;Roo.each(C,function(r){A.renderColumn(r);})}},onBeforeLoad:function(){Roo.log('ds onBeforeLoad');this.clear();},clear:function(){this.el.select('tbody',true).first().dom.innerHTML='';},getSelectionModel:function(){if(!this.selModel){this.selModel=new Roo.bootstrap.Table.RowSelectionModel();}return this.selModel;},renderColumn:function(r){var A=this;r.cfg.render(Roo.get(r.id));if(r.cfg.cn){Roo.each(r.cfg.cn,function(c){var B={id:r.id,cfg:c}
 A.renderColumn(B);})}}});