Roo/grid/Grid.js
authorAlan Knowles <alan@roojs.com>
Fri, 8 May 2020 08:15:26 +0000 (16:15 +0800)
committerAlan Knowles <alan@roojs.com>
Fri, 8 May 2020 08:15:26 +0000 (16:15 +0800)
Roo/grid/Grid.js

index 17d583a..68ebec6 100644 (file)
@@ -502,26 +502,38 @@ Roo.extend(Roo.grid.Grid, Roo.util.Observable, {
         this.view.refresh(true);
     },
     /**
-     * addColumn
+     * addColumns
      * Add's a column, default at the end..
-     * @param {Object} column configuration see {@link Roo.grid.ColumnModel} 
+     
      * @param {int} position to add (default end)
+     * @param {Array} of objects of column configuration see {@link Roo.grid.ColumnModel} 
      */
-    addColumn : function(cfg, pos)
+    addColumns : function(pos, ar)
     {
-        cfg.id = typeof(cfg.id) == 'undefined' ? Roo.id() : cfg.id; // don't normally use this..
-        this.cm.lookup[cfg.id] = cfg;
+        
+        for (var i =0;i< ar.length;i++) {
+            var cfg = ar[i];
+            cfg.id = typeof(cfg.id) == 'undefined' ? Roo.id() : cfg.id; // don't normally use this..
+            this.cm.lookup[cfg.id] = cfg;
+        }
+        
+        
         if (typeof(pos) == 'undefined' || pos >= this.cm.config.length) {
-            this.cm.config.push(cfg);
-            this.view.refresh(true);
-            return;
+            pos = this.cm.config.length; //this.cm.config.push(cfg);
+        } 
+            pos = Math.max(0,pos);
+            ar.shift(ar.length);
+            ar.shift(pos);
+            this.cm.config.splice.call(ar);
+            
+            this.cm.config.splice(pos, 0, cfg);
         }
-        // splice
-        pos = Math.max(0,pos);
-        this.cm.config.splice(pos, 0, cfg);
+        
+        
+        this.view.generateRules(this.cm);
         this.view.refresh(true);
         
-    }
+    },