X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/c930e9176a5a85509c5b0230e2bff5c22a591432..6e39d509471fe9b4e2660e0d1631b350d0c66f40:/docs/source/GridView.html diff --git a/docs/source/GridView.html b/docs/source/GridView.html index 97c50522..4ed86512 100644 --- a/docs/source/GridView.html +++ b/docs/source/GridView.html @@ -1,5 +1,6 @@ + The source code @@ -16,67 +17,7 @@ * @constructor * @param {Object} config */ -Ext.grid.GridView = function(config){ - Ext.apply(this, config); - // These events are only used internally by the grid components - this.addEvents( -
/** - * @event beforerowremoved - * Internal UI Event. Fired before a row is removed. - * @param {Ext.grid.GridView} view - * @param {Number} rowIndex The index of the row to be removed. - * @param {Ext.data.Record} record The Record to be removed - */ - "beforerowremoved", -
/** - * @event beforerowsinserted - * Internal UI Event. Fired before rows are inserted. - * @param {Ext.grid.GridView} view - * @param {Number} firstRow The index of the first row to be inserted. - * @param {Number} lastRow The index of the last row to be inserted. - */ - "beforerowsinserted", -
/** - * @event beforerefresh - * Internal UI Event. Fired before the view is refreshed. - * @param {Ext.grid.GridView} view - */ - "beforerefresh", -
/** - * @event rowremoved - * Internal UI Event. Fired after a row is removed. - * @param {Ext.grid.GridView} view - * @param {Number} rowIndex The index of the row that was removed. - * @param {Ext.data.Record} record The Record that was removed - */ - "rowremoved", -
/** - * @event rowsinserted - * Internal UI Event. Fired after rows are inserted. - * @param {Ext.grid.GridView} view - * @param {Number} firstRow The index of the first inserted. - * @param {Number} lastRow The index of the last row inserted. - */ - "rowsinserted", -
/** - * @event rowupdated - * Internal UI Event. Fired after a row has been updated. - * @param {Ext.grid.GridView} view - * @param {Number} firstRow The index of the row updated. - * @param {Ext.data.record} record The Record backing the row updated. - */ - "rowupdated", -
/** - * @event refresh - * Internal UI Event. Fired after the GridView's body has been refreshed. - * @param {Ext.grid.GridView} view - */ - "refresh" - ); - Ext.grid.GridView.superclass.constructor.call(this); -}; - -Ext.extend(Ext.grid.GridView, Ext.util.Observable, { +Ext.grid.GridView = Ext.extend(Ext.util.Observable, {
/** * Override this function to apply custom CSS classes to rows during rendering. You can also supply custom * parameters to the row template for the current row to customize how it is rendered using the rowParams @@ -154,9 +95,10 @@ viewConfig: { deferEmptyText : true,
/** * @cfg {Number} scrollOffset The amount of space to reserve for the vertical scrollbar - * (defaults to 19 pixels). + * (defaults to undefined). If an explicit value isn't specified, this will be automatically + * calculated. */ - scrollOffset : 19, + scrollOffset : undefined,
/** * @cfg {Boolean} autoFill * Defaults to false. Specify true to have the column widths re-proportioned @@ -177,24 +119,24 @@ viewConfig: { */ forceFit : false,
/** - * @cfg {Array} sortClasses The CSS classes applied to a header when it is sorted. (defaults to ["sort-asc", "sort-desc"]) + * @cfg {Array} sortClasses The CSS classes applied to a header when it is sorted. (defaults to ['sort-asc', 'sort-desc']) */ - sortClasses : ["sort-asc", "sort-desc"], + sortClasses : ['sort-asc', 'sort-desc'],
/** - * @cfg {String} sortAscText The text displayed in the "Sort Ascending" menu item (defaults to "Sort Ascending") + * @cfg {String} sortAscText The text displayed in the 'Sort Ascending' menu item (defaults to 'Sort Ascending') */ - sortAscText : "Sort Ascending", + sortAscText : 'Sort Ascending',
/** - * @cfg {String} sortDescText The text displayed in the "Sort Descending" menu item (defaults to "Sort Descending") + * @cfg {String} sortDescText The text displayed in the 'Sort Descending' menu item (defaults to 'Sort Descending') */ - sortDescText : "Sort Descending", + sortDescText : 'Sort Descending',
/** - * @cfg {String} columnsText The text displayed in the "Columns" menu item (defaults to "Columns") + * @cfg {String} columnsText The text displayed in the 'Columns' menu item (defaults to 'Columns') */ - columnsText : "Columns", + columnsText : 'Columns',
/** - * @cfg {String} selectedRowClass The CSS class applied to a selected row (defaults to "x-grid3-row-selected"). An + * @cfg {String} selectedRowClass The CSS class applied to a selected row (defaults to 'x-grid3-row-selected'). An * example overriding the default styling:

     .x-grid3-row-selected {background-color: yellow;}
@@ -208,7 +150,7 @@ viewConfig: {
     
* @type String */ - selectedRowClass : "x-grid3-row-selected", + selectedRowClass : 'x-grid3-row-selected', // private borderWidth : 2, @@ -224,6 +166,11 @@ viewConfig: { * @cfg {Number} rowSelectorDepth The number of levels to search for rows in event delegation (defaults to 10) */ rowSelectorDepth : 10, + +
/** + * @cfg {Number} rowBodySelectorDepth The number of levels to search for row bodies in event delegation (defaults to 10) + */ + rowBodySelectorDepth : 10,
/** * @cfg {String} cellSelector The selector used to find cells internally (defaults to 'td.x-grid3-cell') @@ -234,10 +181,75 @@ viewConfig: { */ rowSelector : 'div.x-grid3-row', +
/** + * @cfg {String} rowBodySelector The selector used to find row bodies internally (defaults to 'div.x-grid3-row') + */ + rowBodySelector : 'div.x-grid3-row-body', + // private firstRowCls: 'x-grid3-row-first', lastRowCls: 'x-grid3-row-last', rowClsRe: /(?:^|\s+)x-grid3-row-(first|last|alt)(?:\s+|$)/g, + + constructor : function(config){ + Ext.apply(this, config); + // These events are only used internally by the grid components + this.addEvents( +
/** + * @event beforerowremoved + * Internal UI Event. Fired before a row is removed. + * @param {Ext.grid.GridView} view + * @param {Number} rowIndex The index of the row to be removed. + * @param {Ext.data.Record} record The Record to be removed + */ + 'beforerowremoved', +
/** + * @event beforerowsinserted + * Internal UI Event. Fired before rows are inserted. + * @param {Ext.grid.GridView} view + * @param {Number} firstRow The index of the first row to be inserted. + * @param {Number} lastRow The index of the last row to be inserted. + */ + 'beforerowsinserted', +
/** + * @event beforerefresh + * Internal UI Event. Fired before the view is refreshed. + * @param {Ext.grid.GridView} view + */ + 'beforerefresh', +
/** + * @event rowremoved + * Internal UI Event. Fired after a row is removed. + * @param {Ext.grid.GridView} view + * @param {Number} rowIndex The index of the row that was removed. + * @param {Ext.data.Record} record The Record that was removed + */ + 'rowremoved', +
/** + * @event rowsinserted + * Internal UI Event. Fired after rows are inserted. + * @param {Ext.grid.GridView} view + * @param {Number} firstRow The index of the first inserted. + * @param {Number} lastRow The index of the last row inserted. + */ + 'rowsinserted', +
/** + * @event rowupdated + * Internal UI Event. Fired after a row has been updated. + * @param {Ext.grid.GridView} view + * @param {Number} firstRow The index of the row updated. + * @param {Ext.data.record} record The Record backing the row updated. + */ + 'rowupdated', +
/** + * @event refresh + * Internal UI Event. Fired after the GridView's body has been refreshed. + * @param {Ext.grid.GridView} view + */ + 'refresh' + ); + Ext.grid.GridView.superclass.constructor.call(this); + }, /* -------------------------------- UI Specific ----------------------------- */ @@ -303,7 +315,7 @@ viewConfig: { } this.templates = ts; - this.colRe = new RegExp("x-grid3-td-([^\\s]+)", ""); + this.colRe = new RegExp('x-grid3-td-([^\\s]+)', ''); }, // private @@ -350,7 +362,7 @@ viewConfig: { this.mainBody = new E(this.scroller.dom.firstChild); this.focusEl = new E(this.scroller.dom.childNodes[1]); - this.focusEl.swallowEvent("click", true); + this.focusEl.swallowEvent('click', true); this.resizeMarker = new E(cs[1]); this.resizeProxy = new E(cs[2]); @@ -375,7 +387,7 @@ viewConfig: { *

Return the index of the grid column which contains the passed HTMLElement.

* See also {@link #findRowIndex} * @param {HTMLElement} el The target element - * @return The column index, or false if the target element is not within a row of this GridView. + * @return {Number} The column index, or false if the target element is not within a row of this GridView. */ findCellIndex : function(el, requiredCls){ var cell = this.findCell(el); @@ -410,7 +422,7 @@ viewConfig: {
/** * Return the HtmlElement representing the grid row which contains the passed element. * @param {HTMLElement} el The target HTMLElement - * @return The row element, or null if the target element is not within a row of this GridView. + * @return {HTMLElement} The row element, or null if the target element is not within a row of this GridView. */ findRow : function(el){ if(!el){ @@ -423,12 +435,24 @@ viewConfig: { *

Return the index of the grid row which contains the passed HTMLElement.

* See also {@link #findCellIndex} * @param {HTMLElement} el The target HTMLElement - * @return The row index, or false if the target element is not within a row of this GridView. + * @return {Number} The row index, or false if the target element is not within a row of this GridView. */ findRowIndex : function(el){ var r = this.findRow(el); return r ? r.rowIndex : false; }, + +
/** + * Return the HtmlElement representing the grid row body which contains the passed element. + * @param {HTMLElement} el The target HTMLElement + * @return {HTMLElement} The row body element, or null if the target element is not within a row body of this GridView. + */ + findRowBody : function(el){ + if(!el){ + return false; + } + return this.fly(el).findParent(this.rowBodySelector, this.rowBodySelectorDepth); + }, // getter methods for fetching elements dynamically in the grid @@ -520,7 +544,7 @@ viewConfig: { syncScroll : function(){ this.syncHeaderScroll(); var mb = this.scroller.dom; - this.grid.fireEvent("bodyscroll", mb.scrollLeft, mb.scrollTop); + this.grid.fireEvent('bodyscroll', mb.scrollLeft, mb.scrollTop); }, // private @@ -534,7 +558,7 @@ viewConfig: { updateSortIcon : function(col, dir){ var sc = this.sortClasses; var hds = this.mainHd.select('td').removeClass(sc); - hds.item(col).addClass(sc[dir == "DESC" ? 1 : 0]); + hds.item(col).addClass(sc[dir == 'DESC' ? 1 : 0]); }, // private @@ -633,11 +657,11 @@ viewConfig: { c = cs[i]; p.id = c.id; p.css = i === 0 ? 'x-grid3-cell-first ' : (i == last ? 'x-grid3-cell-last ' : ''); - p.attr = p.cellAttr = ""; - p.value = c.renderer(r.data[c.name], p, r, rowIndex, i, ds); + p.attr = p.cellAttr = ''; + p.value = c.renderer.call(c.scope, r.data[c.name], p, r, rowIndex, i, ds); p.style = c.style; if(Ext.isEmpty(p.value)){ - p.value = " "; + p.value = ' '; } if(this.markDirty && r.dirty && Ext.isDefined(r.modified[c.name])){ p.css += ' x-grid3-dirty-cell'; @@ -646,20 +670,20 @@ viewConfig: { } var alt = []; if(stripe && ((rowIndex+1) % 2 === 0)){ - alt[0] = "x-grid3-row-alt"; + alt[0] = 'x-grid3-row-alt'; } if(r.dirty){ - alt[1] = " x-grid3-dirty-row"; + alt[1] = ' x-grid3-dirty-row'; } rp.cols = colCount; if(this.getRowClass){ alt[2] = this.getRowClass(r, rowIndex, rp, ds); } - rp.alt = alt.join(" "); - rp.cells = cb.join(""); + rp.alt = alt.join(' '); + rp.cells = cb.join(''); buf[buf.length] = rt.apply(rp); } - return buf.join(""); + return buf.join(''); }, // private @@ -667,16 +691,24 @@ viewConfig: { if(!this.ds || this.ds.getCount() < 1){ return; } - var rows = this.getRows(); + var rows = this.getRows(), + len = rows.length, + i, r; + skipStripe = skipStripe || !this.grid.stripeRows; startRow = startRow || 0; - Ext.each(rows, function(row, idx){ - row.rowIndex = idx; - row.className = row.className.replace(this.rowClsRe, ' '); - if (!skipStripe && (idx + 1) % 2 === 0) { - row.className += ' x-grid3-row-alt'; - } - }); + for(i = 0; i= last){ + this.fireEvent('beforerowsinserted', this, firstRow, lastRow); this.refresh(); + this.fireEvent('rowsinserted', this, firstRow, lastRow); }else{ if(!isUpdate){ - this.fireEvent("beforerowsinserted", this, firstRow, lastRow); + this.fireEvent('beforerowsinserted', this, firstRow, lastRow); } var html = this.renderRows(firstRow, lastRow), before = this.getRow(firstRow); @@ -1052,7 +1094,7 @@ viewConfig: { Ext.DomHelper.insertHtml('beforeEnd', this.mainBody.dom, html); } if(!isUpdate){ - this.fireEvent("rowsinserted", this, firstRow, lastRow); + this.fireEvent('rowsinserted', this, firstRow, lastRow); this.processRows(firstRow); }else if(firstRow === 0 || firstRow >= last){ //ensure first/last row is kept after an update. @@ -1067,12 +1109,12 @@ viewConfig: { if(dm.getRowCount()<1){ this.refresh(); }else{ - this.fireEvent("beforerowsdeleted", this, firstRow, lastRow); + this.fireEvent('beforerowsdeleted', this, firstRow, lastRow); this.removeRows(firstRow, lastRow); this.processRows(firstRow); - this.fireEvent("rowsdeleted", this, firstRow, lastRow); + this.fireEvent('rowsdeleted', this, firstRow, lastRow); } }, @@ -1094,7 +1136,7 @@ viewConfig: { getColumnWidth : function(col){ var w = this.cm.getColumnWidth(col); if(Ext.isNumber(w)){ - return (Ext.isBorderBox ? w : (w-this.borderWidth > 0 ? w-this.borderWidth:0)) + 'px'; + return (Ext.isBorderBox || (Ext.isWebKit && !Ext.isSafari2) ? w : (w - this.borderWidth > 0 ? w - this.borderWidth : 0)) + 'px'; } return w; }, @@ -1108,7 +1150,7 @@ viewConfig: { fitColumns : function(preventRefresh, onlyExpand, omitColumn){ var cm = this.cm, i; var tw = cm.getTotalWidth(false); - var aw = this.grid.getGridEl().getWidth(true)-this.scrollOffset; + var aw = this.grid.getGridEl().getWidth(true)-this.getScrollOffset(); if(aw < 20){ // not initialized, so don't screw up the default widths return; @@ -1165,7 +1207,7 @@ viewConfig: { var g = this.grid, cm = this.cm; if(!this.userResized && g.autoExpandColumn){ var tw = cm.getTotalWidth(false); - var aw = this.grid.getGridEl().getWidth(true)-this.scrollOffset; + var aw = this.grid.getGridEl().getWidth(true)-this.getScrollOffset(); if(tw != aw){ var ci = cm.getIndexById(g.autoExpandColumn); var currentWidth = cm.getColumnWidth(ci); @@ -1189,6 +1231,7 @@ viewConfig: { cs[i] = { name : (!Ext.isDefined(name) ? this.ds.fields.get(i).name : name), renderer : cm.getRenderer(i), + scope: cm.getRendererScope(i), id : cm.getColumnId(i), style : this.getColumnStyle(i) }; @@ -1203,7 +1246,7 @@ viewConfig: { var colCount = cm.getColumnCount(); if(ds.getCount() < 1){ - return ""; + return ''; } var cs = this.getColumnData(); @@ -1241,7 +1284,7 @@ viewConfig: { this.insertRows(ds, index, index, true); this.getRow(index).rowIndex = index; this.onRemove(ds, record, index+1, true); - this.fireEvent("rowupdated", this, index, record); + this.fireEvent('rowupdated', this, index, record); },
/** @@ -1249,7 +1292,7 @@ viewConfig: { * @param {Boolean} headersToo (optional) True to also refresh the headers */ refresh : function(headersToo){ - this.fireEvent("beforerefresh", this); + this.fireEvent('beforerefresh', this); this.grid.stopEditing(true); var result = this.renderBody(); @@ -1261,7 +1304,7 @@ viewConfig: { this.processRows(0, true); this.layout(); this.applyEmptyText(); - this.fireEvent("refresh", this); + this.fireEvent('refresh', this); }, // private @@ -1288,6 +1331,16 @@ viewConfig: { } }, + // private + clearHeaderSortState : function(){ + if(!this.sortState){ + return; + } + this.grid.fireEvent('sortchange', this.grid, null); + this.mainHd.select('td').removeClass(this.sortClasses); + delete this.sortState; + }, + // private destroy : function(){ if(this.colMenu){ @@ -1300,41 +1353,75 @@ viewConfig: { this.hmenu.destroy(); delete this.hmenu; } + + this.initData(null, null); + this.purgeListeners(); + Ext.fly(this.innerHd).un("click", this.handleHdDown, this); + if(this.grid.enableColumnMove){ - var dds = Ext.dd.DDM.ids['gridHeader' + this.grid.getGridEl().id]; - if(dds){ - for(var dd in dds){ - if(!dds[dd].config.isTarget && dds[dd].dragElId){ - var elid = dds[dd].dragElId; - dds[dd].unreg(); - Ext.get(elid).remove(); - } else if(dds[dd].config.isTarget){ - dds[dd].proxyTop.remove(); - dds[dd].proxyBottom.remove(); - dds[dd].unreg(); - } - if(Ext.dd.DDM.locationCache[dd]){ - delete Ext.dd.DDM.locationCache[dd]; - } - } - delete Ext.dd.DDM.ids['gridHeader' + this.grid.getGridEl().id]; + Ext.destroy( + this.columnDrag.el, + this.columnDrag.proxy.ghost, + this.columnDrag.proxy.el, + this.columnDrop.el, + this.columnDrop.proxyTop, + this.columnDrop.proxyBottom, + this.columnDrag.dragData.ddel, + this.columnDrag.dragData.header + ); + if (this.columnDrag.proxy.anim) { + Ext.destroy(this.columnDrag.proxy.anim); } + delete this.columnDrag.proxy.ghost; + delete this.columnDrag.dragData.ddel; + delete this.columnDrag.dragData.header; + this.columnDrag.destroy(); + delete Ext.dd.DDM.locationCache[this.columnDrag.id]; + delete this.columnDrag._domRef; + + delete this.columnDrop.proxyTop; + delete this.columnDrop.proxyBottom; + this.columnDrop.destroy(); + delete Ext.dd.DDM.locationCache["gridHeader" + this.grid.getGridEl().id]; + delete this.columnDrop._domRef; + delete Ext.dd.DDM.ids[this.columnDrop.ddGroup]; } - if(this.dragZone){ - this.dragZone.unreg(); + if (this.splitZone){ // enableColumnResize + this.splitZone.destroy(); + delete this.splitZone._domRef; + delete Ext.dd.DDM.ids["gridSplitters" + this.grid.getGridEl().id]; } - + Ext.fly(this.innerHd).removeAllListeners(); Ext.removeNode(this.innerHd); - - Ext.destroy(this.resizeMarker, this.resizeProxy, this.focusEl, this.mainBody, - this.scroller, this.mainHd, this.mainWrap, this.dragZone, - this.splitZone, this.columnDrag, this.columnDrop); + delete this.innerHd; + + Ext.destroy( + this.el, + this.mainWrap, + this.mainHd, + this.scroller, + this.mainBody, + this.focusEl, + this.resizeMarker, + this.resizeProxy, + this.activeHdBtn, + this.dragZone, + this.splitZone, + this._flyweight + ); + + delete this.grid.container; + + if(this.dragZone){ + this.dragZone.destroy(); + } + + Ext.dd.DDM.currentTarget = null; + delete Ext.dd.DDM.locationCache[this.grid.getGridEl().id]; - this.initData(null, null); Ext.EventManager.removeResizeListener(this.onWindowResize, this); - this.purgeListeners(); }, // private @@ -1367,12 +1454,12 @@ viewConfig: { // private initData : function(ds, cm){ if(this.ds){ - this.ds.un("load", this.onLoad, this); - this.ds.un("datachanged", this.onDataChange, this); - this.ds.un("add", this.onAdd, this); - this.ds.un("remove", this.onRemove, this); - this.ds.un("update", this.onUpdate, this); - this.ds.un("clear", this.onClear, this); + this.ds.un('load', this.onLoad, this); + this.ds.un('datachanged', this.onDataChange, this); + this.ds.un('add', this.onAdd, this); + this.ds.un('remove', this.onRemove, this); + this.ds.un('update', this.onUpdate, this); + this.ds.un('clear', this.onClear, this); if(this.ds !== ds && this.ds.autoDestroy){ this.ds.destroy(); } @@ -1391,11 +1478,11 @@ viewConfig: { this.ds = ds; if(this.cm){ - this.cm.un("configchange", this.onColConfigChange, this); - this.cm.un("widthchange", this.onColWidthChange, this); - this.cm.un("headerchange", this.onHeaderChange, this); - this.cm.un("hiddenchange", this.onHiddenChange, this); - this.cm.un("columnmoved", this.onColumnMove, this); + this.cm.un('configchange', this.onColConfigChange, this); + this.cm.un('widthchange', this.onColWidthChange, this); + this.cm.un('headerchange', this.onHeaderChange, this); + this.cm.un('hiddenchange', this.onHiddenChange, this); + this.cm.un('columnmoved', this.onColumnMove, this); } if(cm){ delete this.lastViewWidth; @@ -1431,25 +1518,26 @@ viewConfig: { // private onAdd : function(ds, records, index){ + this.insertRows(ds, index, index + (records.length-1)); }, // private onRemove : function(ds, record, index, isUpdate){ if(isUpdate !== true){ - this.fireEvent("beforerowremoved", this, index, record); + this.fireEvent('beforerowremoved', this, index, record); } this.removeRow(index); if(isUpdate !== true){ this.processRows(index); this.applyEmptyText(); - this.fireEvent("rowremoved", this, index, record); + this.fireEvent('rowremoved', this, index, record); } }, // private onLoad : function(){ - this.scrollToTop(); + this.scrollToTop.defer(Ext.isGecko ? 1 : 0, this); }, // private @@ -1487,7 +1575,7 @@ viewConfig: { /* -------------------- UI Events and Handlers ------------------------------ */ // private initUI : function(grid){ - grid.on("headerclick", this.onHeaderClick, this); + grid.on('headerclick', this.onHeaderClick, this); }, // private @@ -1507,7 +1595,7 @@ viewConfig: { onRowOver : function(e, t){ var row; if((row = this.findRowIndex(t)) !== false){ - this.addRowClass(row, "x-grid3-row-over"); + this.addRowClass(row, 'x-grid3-row-over'); } }, @@ -1515,7 +1603,7 @@ viewConfig: { onRowOut : function(e, t){ var row; if((row = this.findRowIndex(t)) !== false && !e.within(this.getRow(row), true)){ - this.removeRowClass(row, "x-grid3-row-over"); + this.removeRowClass(row, 'x-grid3-row-over'); } }, @@ -1538,7 +1626,7 @@ viewConfig: { onCellSelect : function(row, col){ var cell = this.getCell(row, col); if(cell){ - this.fly(cell).addClass("x-grid3-cell-selected"); + this.fly(cell).addClass('x-grid3-cell-selected'); } }, @@ -1546,7 +1634,7 @@ viewConfig: { onCellDeselect : function(row, col){ var cell = this.getCell(row, col); if(cell){ - this.fly(cell).removeClass("x-grid3-cell-selected"); + this.fly(cell).removeClass('x-grid3-cell-selected'); } }, @@ -1564,22 +1652,24 @@ viewConfig: { this.syncHeaderScroll(); } - this.grid.fireEvent("columnresize", i, w); + this.grid.fireEvent('columnresize', i, w); }, // private handleHdMenuClick : function(item){ - var index = this.hdCtxIndex; - var cm = this.cm, ds = this.ds; - switch(item.itemId){ - case "asc": - ds.sort(cm.getDataIndex(index), "ASC"); + var index = this.hdCtxIndex, + cm = this.cm, + ds = this.ds, + id = item.getItemId(); + switch(id){ + case 'asc': + ds.sort(cm.getDataIndex(index), 'ASC'); break; - case "desc": - ds.sort(cm.getDataIndex(index), "DESC"); + case 'desc': + ds.sort(cm.getDataIndex(index), 'DESC'); break; default: - index = cm.getIndexById(item.itemId.substr(4)); + index = cm.getIndexById(id.substr(4)); if(index != -1){ if(item.checked && cm.getColumnsBy(this.isHideableColumn, this).length <= 1){ this.onDenyColumnHide(); @@ -1603,7 +1693,7 @@ viewConfig: { for(var i = 0; i < colCount; i++){ if(cm.config[i].fixed !== true && cm.config[i].hideable !== false){ this.colMenu.add(new Ext.menu.CheckItem({ - itemId: "col-"+cm.getColumnId(i), + itemId: 'col-'+cm.getColumnId(i), text: cm.getColumnHeader(i), checked: !cm.isHidden(i), hideOnClick:false, @@ -1622,12 +1712,12 @@ viewConfig: { var index = this.getCellIndex(hd); this.hdCtxIndex = index; var ms = this.hmenu.items, cm = this.cm; - ms.get("asc").setDisabled(!cm.isSortable(index)); - ms.get("desc").setDisabled(!cm.isSortable(index)); - this.hmenu.on("hide", function(){ + ms.get('asc').setDisabled(!cm.isSortable(index)); + ms.get('desc').setDisabled(!cm.isSortable(index)); + this.hmenu.on('hide', function(){ Ext.fly(hd).removeClass('x-grid3-hd-menu-open'); }, this, {single:true}); - this.hmenu.show(t, "tl-bl?"); + this.hmenu.show(t, 'tl-bl?'); } }, @@ -1635,12 +1725,12 @@ viewConfig: { handleHdOver : function(e, t){ var hd = this.findHeaderCell(t); if(hd && !this.headersDisabled){ - this.activeHd = hd; + this.activeHdRef = t; this.activeHdIndex = this.getCellIndex(hd); var fly = this.fly(hd); this.activeHdRegion = fly.getRegion(); if(!this.cm.isMenuDisabled(this.activeHdIndex)){ - fly.addClass("x-grid3-hd-over"); + fly.addClass('x-grid3-hd-over'); this.activeHdBtn = fly.child('.x-grid3-hd-btn'); if(this.activeHdBtn){ this.activeHdBtn.dom.style.height = (hd.firstChild.offsetHeight-1)+'px'; @@ -1651,18 +1741,21 @@ viewConfig: { // private handleHdMove : function(e, t){ - if(this.activeHd && !this.headersDisabled){ - var hw = this.splitHandleWidth || 5; - var r = this.activeHdRegion; - var x = e.getPageX(); - var ss = this.activeHd.style; - if(x - r.left <= hw && this.cm.isResizable(this.activeHdIndex-1)){ - ss.cursor = Ext.isAir ? 'move' : Ext.isWebKit ? 'e-resize' : 'col-resize'; // col-resize not always supported - }else if(r.right - x <= (!this.activeHdBtn ? hw : 2) && this.cm.isResizable(this.activeHdIndex)){ - ss.cursor = Ext.isAir ? 'move' : Ext.isWebKit ? 'w-resize' : 'col-resize'; - }else{ - ss.cursor = ''; + var hd = this.findHeaderCell(this.activeHdRef); + if(hd && !this.headersDisabled){ + var hw = this.splitHandleWidth || 5, + r = this.activeHdRegion, + x = e.getPageX(), + ss = hd.style, + cur = ''; + if(this.grid.enableColumnResize !== false){ + if(x - r.left <= hw && this.cm.isResizable(this.activeHdIndex-1)){ + cur = Ext.isAir ? 'move' : Ext.isWebKit ? 'e-resize' : 'col-resize'; // col-resize not always supported + }else if(r.right - x <= (!this.activeHdBtn ? hw : 2) && this.cm.isResizable(this.activeHdIndex)){ + cur = Ext.isAir ? 'move' : Ext.isWebKit ? 'w-resize' : 'col-resize'; + } } + ss.cursor = cur; } }, @@ -1670,8 +1763,8 @@ viewConfig: { handleHdOut : function(e, t){ var hd = this.findHeaderCell(t); if(hd && (!Ext.isIE || !e.within(hd, true))){ - this.activeHd = null; - this.fly(hd).removeClass("x-grid3-hd-over"); + this.activeHdRef = null; + this.fly(hd).removeClass('x-grid3-hd-over'); hd.style.cursor = ''; } }, @@ -1697,7 +1790,7 @@ Ext.grid.GridView.SplitDragZone = function(grid, hd){ this.marker = this.view.resizeMarker; this.proxy = this.view.resizeProxy; Ext.grid.GridView.SplitDragZone.superclass.constructor.call(this, hd, - "gridSplitters" + this.grid.getGridEl().id, { + 'gridSplitters' + this.grid.getGridEl().id, { dragElId : Ext.id(this.proxy.dom), resizeFrame:false }); this.scroll = false; @@ -1722,11 +1815,15 @@ Ext.extend(Ext.grid.GridView.SplitDragZone, Ext.dd.DDProxy, { this.startPos = x; Ext.dd.DDProxy.prototype.b4StartDrag.call(this, x, y); }, + + allowHeaderDrag : function(e){ + return true; + }, handleMouseDown : function(e){ var t = this.view.findHeaderCell(e.getTarget()); - if(t){ + if(t && this.allowHeaderDrag(e)){ var xy = this.view.fly(t).getXY(), x = xy[0], y = xy[1]; var exy = e.getXY(), ex = exy[0]; var w = t.offsetWidth, adjust = false;