From: Alan Knowles Date: Fri, 8 May 2020 08:15:26 +0000 (+0800) Subject: Roo/grid/Grid.js X-Git-Url: http://git.roojs.org/?p=roojs1;a=commitdiff_plain;h=7b3136ed829b2a91960544fe5920c668c86cc054 Roo/grid/Grid.js --- diff --git a/Roo/grid/Grid.js b/Roo/grid/Grid.js index 17d583a69f..68ebec6344 100644 --- a/Roo/grid/Grid.js +++ b/Roo/grid/Grid.js @@ -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); - } + },