X-Git-Url: http://git.roojs.org/?p=roojs1;a=blobdiff_plain;f=Roo%2Fgrid%2FGrid.js;h=473270564dea5a88c9437fe5f310c6dc6f03981c;hp=d33b170b39c6144b48ce0d26d2af70f51fd302e3;hb=8673c23959602f121d1fb75c6a7ec7a656352897;hpb=c31a60a12e6f65b43a8f735d9e656f20191b0d0b diff --git a/Roo/grid/Grid.js b/Roo/grid/Grid.js index d33b170b39..473270564d 100644 --- a/Roo/grid/Grid.js +++ b/Roo/grid/Grid.js @@ -449,7 +449,7 @@ Roo.extend(Roo.grid.Grid, Roo.util.Observable, { c.on("contextmenu", this.onContextMenu, this); c.on("keydown", this.onKeyDown, this); if (Roo.isTouch) { - c.on("touchend", this.onTouch, this); + c.on("touchstart", this.onTouchStart, this); } this.relayEvents(c, ["mousedown","mouseup","mouseover","mouseout","keypress"]); @@ -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); @@ -531,24 +565,26 @@ Roo.extend(Roo.grid.Grid, Roo.util.Observable, { // private processEvent : function(name, e){ // does this fire select??? - Roo.log('grid:processEvent ' + name); - if (Roo.isTouch && name == 'click') { - return; + //Roo.log('grid:processEvent ' + name); + + if (name != 'touchstart' ) { + this.fireEvent(name, e); } - this.fireEvent(name == 'touchend' ? 'click' : name, e); var t = e.getTarget(); var v = this.view; var header = v.findHeaderIndex(t); if(header !== false){ - this.fireEvent("header" + name, this, header, e); + var ename = name == 'touchstart' ? 'click' : name; + + this.fireEvent("header" + ename, this, header, e); }else{ var row = v.findRowIndex(t); var cell = v.findCellIndex(t); - if (name == 'touchend') { + if (name == 'touchstart') { // first touch is always a click. // hopefull this happens after selection is updated.? - name = 'click'; + name = false; if (typeof(this.selModel.getSelectedCell) != 'undefined') { var cs = this.selModel.getSelectedCell(); @@ -563,7 +599,9 @@ Roo.extend(Roo.grid.Grid, Roo.util.Observable, { name = 'dblclick'; } } - + if (!name) { + return; + } } @@ -581,8 +619,8 @@ Roo.extend(Roo.grid.Grid, Roo.util.Observable, { this.processEvent("click", e); }, // private - onTouch : function(e){ - this.processEvent("touch", e); + onTouchStart : function(e){ + this.processEvent("touchstart", e); }, // private