X-Git-Url: http://git.roojs.org/?p=roojs1;a=blobdiff_plain;f=Roo%2Fgrid%2FGrid.js;h=473270564dea5a88c9437fe5f310c6dc6f03981c;hp=9f782eb6d2e220adbb16cda64b76d38c84cd50e1;hb=8673c23959602f121d1fb75c6a7ec7a656352897;hpb=05b7c68f0793495411e3e887922cf8493e963bb4 diff --git a/Roo/grid/Grid.js b/Roo/grid/Grid.js index 9f782eb6d2..473270564d 100644 --- a/Roo/grid/Grid.js +++ b/Roo/grid/Grid.js @@ -62,7 +62,7 @@ Roo.grid.Grid = function(container, config){ this.selModel = this.sm; delete this.sm; } - Roo.log(this.colModel);return; + if (this.selModel) { this.selModel = Roo.factory(this.selModel, Roo.grid); this.sm = this.selModel; @@ -484,12 +484,12 @@ Roo.extend(Roo.grid.Grid, Roo.util.Observable, { return this; }, - /** - * Reconfigures the grid to use a different Store and Column Model. - * The View will be bound to the new objects and refreshed. - * @param {Roo.data.Store} dataSource The new {@link Roo.data.Store} object - * @param {Roo.grid.ColumnModel} The new {@link Roo.grid.ColumnModel} object - */ + /** + * Reconfigures the grid to use a different Store and Column Model. + * The View will be bound to the new objects and refreshed. + * @param {Roo.data.Store} dataSource The new {@link Roo.data.Store} object + * @param {Roo.grid.ColumnModel} The new {@link Roo.grid.ColumnModel} object + */ reconfigure : function(dataSource, colModel){ if(this.loadMask){ this.loadMask.destroy(); @@ -501,7 +501,41 @@ Roo.extend(Roo.grid.Grid, Roo.util.Observable, { this.colModel = colModel; this.view.refresh(true); }, - + /** + * addColumns + * Add's a column, default at the end.. + + * @param {int} position to add (default end) + * @param {Array} of objects of column configuration see {@link Roo.grid.ColumnModel} + */ + addColumns : function(pos, ar) + { + + 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) { + pos = this.cm.config.length; //this.cm.config.push(cfg); + } + pos = Math.max(0,pos); + ar.unshift(0); + ar.unshift(pos); + this.cm.config.splice.apply(this.cm.config, ar); + + + + this.view.generateRules(this.cm); + this.view.refresh(true); + + }, + + + + // private onKeyDown : function(e){ this.fireEvent("keydown", e);