X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=Roo%2Fgrid%2FGrid.js;h=14d4a7a11120f9105d7a7e31380e9e72d9ef6afa;hb=6769ede9cd70d738a188f2d4314738d171b50deb;hp=14d002d818318f1b1d798671dd44bc617ee26c91;hpb=2032edc6a0478c95e690c602d7c0eeaeeec8de14;p=roojs1 diff --git a/Roo/grid/Grid.js b/Roo/grid/Grid.js index 14d002d818..14d4a7a111 100644 --- a/Roo/grid/Grid.js +++ b/Roo/grid/Grid.js @@ -448,6 +448,9 @@ Roo.extend(Roo.grid.Grid, Roo.util.Observable, { c.on("dblclick", this.onDblClick, this); c.on("contextmenu", this.onContextMenu, this); c.on("keydown", this.onKeyDown, this); + if (Roo.isTouch) { + c.on("touchstart", this.onTouchStart, this); + } this.relayEvents(c, ["mousedown","mouseup","mouseover","mouseout","keypress"]); @@ -472,7 +475,7 @@ Roo.extend(Roo.grid.Grid, Roo.util.Observable, { } if (this.dropTarget && this.dropTarget.xtype) { delete this.dropTarget.xtype; - this.dropTarget = new Ext.dd.DropTarget(this.getView().mainBody, this.dropTarget); + this.dropTarget = new Roo.dd.DropTarget(this.getView().mainBody, this.dropTarget); } @@ -481,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(); @@ -498,7 +501,22 @@ Roo.extend(Roo.grid.Grid, Roo.util.Observable, { this.colModel = colModel; this.view.refresh(true); }, - + /** + * addColumn + * Add's a column, default at the end.. + * @param {Object} column configuration see {@link Roo.grid.ColumnModel} + * @param {int} position to add (default end) + */ + addColumn : function(cfg, pos) + { + cfg.id = typeof(cfg.id) == 'undefined' : Roo.id() : cfg.id; // don't normally use this.. + + + } + + + + // private onKeyDown : function(e){ this.fireEvent("keydown", e); @@ -527,15 +545,47 @@ Roo.extend(Roo.grid.Grid, Roo.util.Observable, { // private processEvent : function(name, e){ - this.fireEvent(name, e); + // does this fire select??? + //Roo.log('grid:processEvent ' + name); + + if (name != 'touchstart' ) { + this.fireEvent(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 == 'touchstart') { + // first touch is always a click. + // hopefull this happens after selection is updated.? + name = false; + + if (typeof(this.selModel.getSelectedCell) != 'undefined') { + var cs = this.selModel.getSelectedCell(); + if (row == cs[0] && cell == cs[1]){ + name = 'dblclick'; + } + } + if (typeof(this.selModel.getSelections) != 'undefined') { + var cs = this.selModel.getSelections(); + var ds = this.dataSource; + if (cs.length == 1 && ds.getAt(row) == cs[0]){ + name = 'dblclick'; + } + } + if (!name) { + return; + } + } + + if(row !== false){ this.fireEvent("row" + name, this, row, e); if(cell !== false){ @@ -549,6 +599,10 @@ Roo.extend(Roo.grid.Grid, Roo.util.Observable, { onClick : function(e){ this.processEvent("click", e); }, + // private + onTouchStart : function(e){ + this.processEvent("touchstart", e); + }, // private onContextMenu : function(e, t){