Roo/form/ComboBoxArray.js
[roojs1] / roojs-bootstrap-debug.js
index 9e425f2..5592037 100644 (file)
@@ -2950,6 +2950,11 @@ Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component,  {
         
         Roo.log('initEvents with ds!!!!');
         
+        var _this = this;
+        
+        Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
+            e.on('click', _this.sort, _this);
+        });
 //        this.maskEl = Roo.DomHelper.append(this.el.select('.TableGrid', true).first(), {tag: "div", cls:"x-dlg-mask"}, true);
 //        this.maskEl.enableDisplayMode("block");
 //        this.maskEl.show();
@@ -2963,6 +2968,26 @@ Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component,  {
         
     },
     
+    sort : function(e,el)
+    {
+        var col = Roo.get(el)
+        
+        if(!col.hasClass('sortable')){
+            return;
+        }
+        
+        var sort = col.attr('sort');
+        var dir = 'ASC';
+        
+        if(col.hasClass('glyphicon-arrow-up')){
+            dir = 'DESC';
+        }
+        
+        this.store.sortInfo = {field : sort, direction : dir};
+        
+        this.store.load();
+    },
+    
     renderHeader : function()
     {
         var header = {
@@ -2973,10 +2998,27 @@ Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component,  {
         var cm = this.cm;
         
         for(var i = 0, len = cm.getColumnCount(); i < len; i++){
-            header.cn.push({
+            
+            var config = cm.config[i];
+            
+            var c = {
                 tag: 'th',
                 html: cm.getColumnHeader(i)
-            })
+            };
+            
+            if(typeof(config.dataIndex) != 'undefined'){
+                c.sort = config.dataIndex;
+            }
+            
+            if(typeof(config.sortable) != 'undefined' && config.sortable){
+                c.cls = 'sortable';
+            }
+            
+            if(typeof(config.width) != 'undefined'){
+                c.style = 'width:' + config.width + 'px';
+            }
+            
+            header.cn.push(c)
         }
         
         return header;
@@ -3006,8 +3048,21 @@ Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component,  {
     {
         Roo.log('ds onload');
         
+        var _this = 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']);
+            
+            if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'ASC'){
+                e.addClass(['glyphicon', 'glyphicon-arrow-up']);
+            }
+            
+            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();
         
         var renders = [];
@@ -3021,6 +3076,7 @@ Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component,  {
                 
                 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
                     var renderer = cm.getRenderer(i);
+                    var config = cm.config[i];
                     var value = '';
                     var id = Roo.id();
                     
@@ -3035,11 +3091,17 @@ Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component,  {
                         })
                     }
                     
-                    row.cn.push({
+                    var td = {
                         tag: 'td',
                         id: id,
                         html: (typeof(value) === 'object') ? '' : value
-                    })
+                    };
+                    
+                    if(typeof(config.width) != 'undefined'){
+                        td.style = 'width:' +  config.width + 'px';
+                    }
+                    
+                    row.cn.push(td);
                    
                 }
                 
@@ -6723,6 +6785,18 @@ Roo.extend(Roo.data.Store, Roo.util.Observable, {
         this.sortInfo = meta.sortInfo || this.sortInfo;
         this.modified = [];
         this.fireEvent('metachange', this, this.reader.meta);
+    },
+    
+    moveIndex : function(data, type)
+    {
+        var index = this.indexOf(data);
+        
+        var newIndex = index + type;
+        
+        this.remove(data);
+        
+        this.insert(newIndex, data);
+        
     }
 });/*
  * Based on:
@@ -12562,6 +12636,8 @@ Roo.extend(Roo.bootstrap.CheckBox, Roo.bootstrap.Input,  {
     {
         this.checked = state;
         
+        this.inputEl().dom.checked = state;
+        
         if(suppressEvent !== true){
             this.fireEvent('check', this, state);
         }
@@ -12570,10 +12646,9 @@ Roo.extend(Roo.bootstrap.CheckBox, Roo.bootstrap.Input,  {
         
     },
     
-    setValue : function(v)
+    setValue : function(v,suppressEvent)
     {
-        Roo.log('run set value of checkbox!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
-        this.setChecked(String(v) === String(this.inputValue));
+        this.setChecked(((typeof(v) == 'undefined') ? this.checked : (String(v) === String(this.inputValue))), suppressEvent);
     }
     
 });
@@ -12744,9 +12819,11 @@ Roo.extend(Roo.bootstrap.Radio, Roo.bootstrap.CheckBox,  {
     
     setChecked : function(state,suppressEvent)
     {
-        Roo.each(this.inputEl().up('form').select('input[name='+this.inputEl().dom.name+']', true).elements, function(v){
-            v.dom.checked = false;
-        });
+        if(state){
+            Roo.each(this.inputEl().up('form').select('input[name='+this.inputEl().dom.name+']', true).elements, function(v){
+                v.dom.checked = false;
+            });
+        }
         
         this.checked = state;
         this.inputEl().dom.checked = state;
@@ -12901,6 +12978,8 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component,  {
     iframePad:3,
     hideMode:'offsets',
     
+    clearUp: true,
+    
      
     
 
@@ -13719,7 +13798,8 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component,  {
     cleanUpPaste :  function()
     {
         // cleans up the whole document..
-         Roo.log('cleanuppaste');
+        Roo.log('cleanuppaste');
+        
         this.cleanUpChildren(this.doc.body);
         var clean = this.cleanWordChars(this.doc.body.innerHTML);
         if (clean != this.doc.body.innerHTML) {
@@ -13769,7 +13849,7 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component,  {
             return; 
         }
         
-        if (Roo.HtmlEditorCore.black.indexOf(node.tagName.toLowerCase()) > -1) {
+        if (Roo.HtmlEditorCore.black.indexOf(node.tagName.toLowerCase()) > -1 && this.clearUp) {
             // remove node.
             node.parentNode.removeChild(node);
             return;
@@ -13840,7 +13920,6 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component,  {
                 var l = p.split(':').shift().replace(/\s+/g,'');
                 l = l.replace(/^\s+/g,'').replace(/\s+$/g,'');
                 
-                
                 if ( cblack.indexOf(l) > -1) {
 //                    Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
                     //node.removeAttribute(n);