3 * Copyright(c) 2006-2009 Ext JS, LLC
5 * http://www.extjs.com/license
8 * @class Ext.grid.GridView
9 * @extends Ext.util.Observable
10 * <p>This class encapsulates the user interface of an {@link Ext.grid.GridPanel}.
11 * Methods of this class may be used to access user interface elements to enable
12 * special display effects. Do not change the DOM structure of the user interface.</p>
13 * <p>This class does not provide ways to manipulate the underlying data. The data
14 * model of a Grid is held in an {@link Ext.data.Store}.</p>
16 * @param {Object} config
18 Ext.grid.GridView = Ext.extend(Ext.util.Observable, {
20 * Override this function to apply custom CSS classes to rows during rendering. You can also supply custom
21 * parameters to the row template for the current row to customize how it is rendered using the <b>rowParams</b>
22 * parameter. This function should return the CSS class name (or empty string '' for none) that will be added
23 * to the row's wrapping div. To apply multiple class names, simply return them space-delimited within the string
24 * (e.g., 'my-class another-class'). Example usage:
28 showPreview: true, // custom property
29 enableRowBody: true, // required to create a second, full-width row to show expanded Record data
30 getRowClass: function(record, rowIndex, rp, ds){ // rp = rowParams
32 rp.body = '<p>'+record.data.excerpt+'</p>';
33 return 'x-grid3-row-expanded';
35 return 'x-grid3-row-collapsed';
39 * @param {Record} record The {@link Ext.data.Record} corresponding to the current row.
40 * @param {Number} index The row index.
41 * @param {Object} rowParams A config object that is passed to the row template during rendering that allows
42 * customization of various aspects of a grid row.
43 * <p>If {@link #enableRowBody} is configured <b><tt></tt>true</b>, then the following properties may be set
44 * by this function, and will be used to render a full-width expansion row below each grid row:</p>
46 * <li><code>body</code> : String <div class="sub-desc">An HTML fragment to be used as the expansion row's body content (defaults to '').</div></li>
47 * <li><code>bodyStyle</code> : String <div class="sub-desc">A CSS style specification that will be applied to the expansion row's <tr> element. (defaults to '').</div></li>
49 * The following property will be passed in, and may be appended to:
51 * <li><code>tstyle</code> : String <div class="sub-desc">A CSS style specification that willl be applied to the <table> element which encapsulates
52 * both the standard grid row, and any expansion row.</div></li>
54 * @param {Store} store The {@link Ext.data.Store} this grid is bound to
56 * @return {String} a CSS class name to add to the row.
59 * @cfg {Boolean} enableRowBody True to add a second TR element per row that can be used to provide a row body
60 * that spans beneath the data row. Use the {@link #getRowClass} method's rowParams config to customize the row body.
63 * @cfg {String} emptyText Default text (html tags are accepted) to display in the grid body when no rows
64 * are available (defaults to ''). This value will be used to update the <tt>{@link #mainBody}</tt>:
66 this.mainBody.update('<div class="x-grid-empty">' + this.emptyText + '</div>');
70 * @cfg {Boolean} headersDisabled True to disable the grid column headers (defaults to <tt>false</tt>).
71 * Use the {@link Ext.grid.ColumnModel ColumnModel} <tt>{@link Ext.grid.ColumnModel#menuDisabled menuDisabled}</tt>
72 * config to disable the <i>menu</i> for individual columns. While this config is true the
73 * following will be disabled:<div class="mdetail-params"><ul>
74 * <li>clicking on header to sort</li>
75 * <li>the trigger to reveal the menu.</li>
79 * <p>A customized implementation of a {@link Ext.dd.DragZone DragZone} which provides default implementations
80 * of the template methods of DragZone to enable dragging of the selected rows of a GridPanel.
81 * See {@link Ext.grid.GridDragZone} for details.</p>
82 * <p>This will <b>only</b> be present:<div class="mdetail-params"><ul>
83 * <li><i>if</i> the owning GridPanel was configured with {@link Ext.grid.GridPanel#enableDragDrop enableDragDrop}: <tt>true</tt>.</li>
84 * <li><i>after</i> the owning GridPanel has been rendered.</li>
87 * @type {Ext.grid.GridDragZone}
90 * @cfg {Boolean} deferEmptyText True to defer <tt>{@link #emptyText}</tt> being applied until the store's
91 * first load (defaults to <tt>true</tt>).
93 deferEmptyText : true,
95 * @cfg {Number} scrollOffset The amount of space to reserve for the vertical scrollbar
96 * (defaults to <tt>undefined</tt>). If an explicit value isn't specified, this will be automatically
99 scrollOffset : undefined,
101 * @cfg {Boolean} autoFill
102 * Defaults to <tt>false</tt>. Specify <tt>true</tt> to have the column widths re-proportioned
103 * when the grid is <b>initially rendered</b>. The
104 * {@link Ext.grid.Column#width initially configured width}</tt> of each column will be adjusted
105 * to fit the grid width and prevent horizontal scrolling. If columns are later resized (manually
106 * or programmatically), the other columns in the grid will <b>not</b> be resized to fit the grid width.
107 * See <tt>{@link #forceFit}</tt> also.
111 * @cfg {Boolean} forceFit
112 * Defaults to <tt>false</tt>. Specify <tt>true</tt> to have the column widths re-proportioned
113 * at <b>all times</b>. The {@link Ext.grid.Column#width initially configured width}</tt> of each
114 * column will be adjusted to fit the grid width and prevent horizontal scrolling. If columns are
115 * later resized (manually or programmatically), the other columns in the grid <b>will</b> be resized
116 * to fit the grid width. See <tt>{@link #autoFill}</tt> also.
120 * @cfg {Array} sortClasses The CSS classes applied to a header when it is sorted. (defaults to <tt>['sort-asc', 'sort-desc']</tt>)
122 sortClasses : ['sort-asc', 'sort-desc'],
124 * @cfg {String} sortAscText The text displayed in the 'Sort Ascending' menu item (defaults to <tt>'Sort Ascending'</tt>)
126 sortAscText : 'Sort Ascending',
128 * @cfg {String} sortDescText The text displayed in the 'Sort Descending' menu item (defaults to <tt>'Sort Descending'</tt>)
130 sortDescText : 'Sort Descending',
132 * @cfg {String} columnsText The text displayed in the 'Columns' menu item (defaults to <tt>'Columns'</tt>)
134 columnsText : 'Columns',
137 * @cfg {String} selectedRowClass The CSS class applied to a selected row (defaults to <tt>'x-grid3-row-selected'</tt>). An
138 * example overriding the default styling:
140 .x-grid3-row-selected {background-color: yellow;}
142 * Note that this only controls the row, and will not do anything for the text inside it. To style inner
143 * facets (like text) use something like:
145 .x-grid3-row-selected .x-grid3-cell-inner {
151 selectedRowClass : 'x-grid3-row-selected',
155 tdClass : 'x-grid3-cell',
156 hdCls : 'x-grid3-hd',
160 * @cfg {Number} cellSelectorDepth The number of levels to search for cells in event delegation (defaults to <tt>4</tt>)
162 cellSelectorDepth : 4,
164 * @cfg {Number} rowSelectorDepth The number of levels to search for rows in event delegation (defaults to <tt>10</tt>)
166 rowSelectorDepth : 10,
169 * @cfg {Number} rowBodySelectorDepth The number of levels to search for row bodies in event delegation (defaults to <tt>10</tt>)
171 rowBodySelectorDepth : 10,
174 * @cfg {String} cellSelector The selector used to find cells internally (defaults to <tt>'td.x-grid3-cell'</tt>)
176 cellSelector : 'td.x-grid3-cell',
178 * @cfg {String} rowSelector The selector used to find rows internally (defaults to <tt>'div.x-grid3-row'</tt>)
180 rowSelector : 'div.x-grid3-row',
183 * @cfg {String} rowBodySelector The selector used to find row bodies internally (defaults to <tt>'div.x-grid3-row'</tt>)
185 rowBodySelector : 'div.x-grid3-row-body',
188 firstRowCls: 'x-grid3-row-first',
189 lastRowCls: 'x-grid3-row-last',
190 rowClsRe: /(?:^|\s+)x-grid3-row-(first|last|alt)(?:\s+|$)/g,
192 constructor : function(config){
193 Ext.apply(this, config);
194 // These events are only used internally by the grid components
197 * @event beforerowremoved
198 * Internal UI Event. Fired before a row is removed.
199 * @param {Ext.grid.GridView} view
200 * @param {Number} rowIndex The index of the row to be removed.
201 * @param {Ext.data.Record} record The Record to be removed
205 * @event beforerowsinserted
206 * Internal UI Event. Fired before rows are inserted.
207 * @param {Ext.grid.GridView} view
208 * @param {Number} firstRow The index of the first row to be inserted.
209 * @param {Number} lastRow The index of the last row to be inserted.
211 'beforerowsinserted',
213 * @event beforerefresh
214 * Internal UI Event. Fired before the view is refreshed.
215 * @param {Ext.grid.GridView} view
220 * Internal UI Event. Fired after a row is removed.
221 * @param {Ext.grid.GridView} view
222 * @param {Number} rowIndex The index of the row that was removed.
223 * @param {Ext.data.Record} record The Record that was removed
227 * @event rowsinserted
228 * Internal UI Event. Fired after rows are inserted.
229 * @param {Ext.grid.GridView} view
230 * @param {Number} firstRow The index of the first inserted.
231 * @param {Number} lastRow The index of the last row inserted.
236 * Internal UI Event. Fired after a row has been updated.
237 * @param {Ext.grid.GridView} view
238 * @param {Number} firstRow The index of the row updated.
239 * @param {Ext.data.record} record The Record backing the row updated.
244 * Internal UI Event. Fired after the GridView's body has been refreshed.
245 * @param {Ext.grid.GridView} view
249 Ext.grid.GridView.superclass.constructor.call(this);
252 /* -------------------------------- UI Specific ----------------------------- */
255 initTemplates : function(){
256 var ts = this.templates || {};
258 ts.master = new Ext.Template(
259 '<div class="x-grid3" hidefocus="true">',
260 '<div class="x-grid3-viewport">',
261 '<div class="x-grid3-header"><div class="x-grid3-header-inner"><div class="x-grid3-header-offset" style="{ostyle}">{header}</div></div><div class="x-clear"></div></div>',
262 '<div class="x-grid3-scroller"><div class="x-grid3-body" style="{bstyle}">{body}</div><a href="#" class="x-grid3-focus" tabIndex="-1"></a></div>',
264 '<div class="x-grid3-resize-marker"> </div>',
265 '<div class="x-grid3-resize-proxy"> </div>',
271 ts.header = new Ext.Template(
272 '<table border="0" cellspacing="0" cellpadding="0" style="{tstyle}">',
273 '<thead><tr class="x-grid3-hd-row">{cells}</tr></thead>',
279 ts.hcell = new Ext.Template(
280 '<td class="x-grid3-hd x-grid3-cell x-grid3-td-{id} {css}" style="{style}"><div {tooltip} {attr} class="x-grid3-hd-inner x-grid3-hd-{id}" unselectable="on" style="{istyle}">', this.grid.enableHdMenu ? '<a class="x-grid3-hd-btn" href="#"></a>' : '',
281 '{value}<img class="x-grid3-sort-icon" src="', Ext.BLANK_IMAGE_URL, '" />',
287 ts.body = new Ext.Template('{rows}');
291 ts.row = new Ext.Template(
292 '<div class="x-grid3-row {alt}" style="{tstyle}"><table class="x-grid3-row-table" border="0" cellspacing="0" cellpadding="0" style="{tstyle}">',
293 '<tbody><tr>{cells}</tr>',
294 (this.enableRowBody ? '<tr class="x-grid3-row-body-tr" style="{bodyStyle}"><td colspan="{cols}" class="x-grid3-body-cell" tabIndex="0" hidefocus="on"><div class="x-grid3-row-body">{body}</div></td></tr>' : ''),
295 '</tbody></table></div>'
300 ts.cell = new Ext.Template(
301 '<td class="x-grid3-col x-grid3-cell x-grid3-td-{id} {css}" style="{style}" tabIndex="0" {cellAttr}>',
302 '<div class="x-grid3-cell-inner x-grid3-col-{id}" unselectable="on" {attr}>{value}</div>',
309 if(t && Ext.isFunction(t.compile) && !t.compiled){
310 t.disableFormats = true;
316 this.colRe = new RegExp('x-grid3-td-([^\\s]+)', '');
321 if(!this._flyweight){
322 this._flyweight = new Ext.Element.Flyweight(document.body);
324 this._flyweight.dom = el;
325 return this._flyweight;
329 getEditorParent : function(){
330 return this.scroller.dom;
334 initElements : function(){
337 var el = this.grid.getGridEl().dom.firstChild;
338 var cs = el.childNodes;
342 this.mainWrap = new E(cs[0]);
343 this.mainHd = new E(this.mainWrap.dom.firstChild);
345 if(this.grid.hideHeaders){
346 this.mainHd.setDisplayed(false);
349 this.innerHd = this.mainHd.dom.firstChild;
350 this.scroller = new E(this.mainWrap.dom.childNodes[1]);
352 this.scroller.setStyle('overflow-x', 'hidden');
355 * <i>Read-only</i>. The GridView's body Element which encapsulates all rows in the Grid.
356 * This {@link Ext.Element Element} is only available after the GridPanel has been rendered.
360 this.mainBody = new E(this.scroller.dom.firstChild);
362 this.focusEl = new E(this.scroller.dom.childNodes[1]);
363 this.focusEl.swallowEvent('click', true);
365 this.resizeMarker = new E(cs[1]);
366 this.resizeProxy = new E(cs[2]);
370 getRows : function(){
371 return this.hasRows() ? this.mainBody.dom.childNodes : [];
374 // finder methods, used with delegation
377 findCell : function(el){
381 return this.fly(el).findParent(this.cellSelector, this.cellSelectorDepth);
385 * <p>Return the index of the grid column which contains the passed HTMLElement.</p>
386 * See also {@link #findRowIndex}
387 * @param {HTMLElement} el The target element
388 * @return {Number} The column index, or <b>false</b> if the target element is not within a row of this GridView.
390 findCellIndex : function(el, requiredCls){
391 var cell = this.findCell(el);
392 if(cell && (!requiredCls || this.fly(cell).hasClass(requiredCls))){
393 return this.getCellIndex(cell);
399 getCellIndex : function(el){
401 var m = el.className.match(this.colRe);
403 return this.cm.getIndexById(m[1]);
410 findHeaderCell : function(el){
411 var cell = this.findCell(el);
412 return cell && this.fly(cell).hasClass(this.hdCls) ? cell : null;
416 findHeaderIndex : function(el){
417 return this.findCellIndex(el, this.hdCls);
421 * Return the HtmlElement representing the grid row which contains the passed element.
422 * @param {HTMLElement} el The target HTMLElement
423 * @return {HTMLElement} The row element, or null if the target element is not within a row of this GridView.
425 findRow : function(el){
429 return this.fly(el).findParent(this.rowSelector, this.rowSelectorDepth);
433 * <p>Return the index of the grid row which contains the passed HTMLElement.</p>
434 * See also {@link #findCellIndex}
435 * @param {HTMLElement} el The target HTMLElement
436 * @return {Number} The row index, or <b>false</b> if the target element is not within a row of this GridView.
438 findRowIndex : function(el){
439 var r = this.findRow(el);
440 return r ? r.rowIndex : false;
444 * Return the HtmlElement representing the grid row body which contains the passed element.
445 * @param {HTMLElement} el The target HTMLElement
446 * @return {HTMLElement} The row body element, or null if the target element is not within a row body of this GridView.
448 findRowBody : function(el){
452 return this.fly(el).findParent(this.rowBodySelector, this.rowBodySelectorDepth);
455 // getter methods for fetching elements dynamically in the grid
458 * Return the <tt><div></tt> HtmlElement which represents a Grid row for the specified index.
459 * @param {Number} index The row index
460 * @return {HtmlElement} The div element.
462 getRow : function(row){
463 return this.getRows()[row];
467 * Returns the grid's <tt><td></tt> HtmlElement at the specified coordinates.
468 * @param {Number} row The row index in which to find the cell.
469 * @param {Number} col The column index of the cell.
470 * @return {HtmlElement} The td at the specified coordinates.
472 getCell : function(row, col){
473 return this.getRow(row).getElementsByTagName('td')[col];
477 * Return the <tt><td></tt> HtmlElement which represents the Grid's header cell for the specified column index.
478 * @param {Number} index The column index
479 * @return {HtmlElement} The td element.
481 getHeaderCell : function(index){
482 return this.mainHd.dom.getElementsByTagName('td')[index];
485 // manipulating elements
487 // private - use getRowClass to apply custom row classes
488 addRowClass : function(row, cls){
489 var r = this.getRow(row);
491 this.fly(r).addClass(cls);
496 removeRowClass : function(row, cls){
497 var r = this.getRow(row);
499 this.fly(r).removeClass(cls);
504 removeRow : function(row){
505 Ext.removeNode(this.getRow(row));
506 this.syncFocusEl(row);
510 removeRows : function(firstRow, lastRow){
511 var bd = this.mainBody.dom;
512 for(var rowIndex = firstRow; rowIndex <= lastRow; rowIndex++){
513 Ext.removeNode(bd.childNodes[firstRow]);
515 this.syncFocusEl(firstRow);
521 getScrollState : function(){
522 var sb = this.scroller.dom;
523 return {left: sb.scrollLeft, top: sb.scrollTop};
527 restoreScroll : function(state){
528 var sb = this.scroller.dom;
529 sb.scrollLeft = state.left;
530 sb.scrollTop = state.top;
534 * Scrolls the grid to the top
536 scrollToTop : function(){
537 this.scroller.dom.scrollTop = 0;
538 this.scroller.dom.scrollLeft = 0;
542 syncScroll : function(){
543 this.syncHeaderScroll();
544 var mb = this.scroller.dom;
545 this.grid.fireEvent('bodyscroll', mb.scrollLeft, mb.scrollTop);
549 syncHeaderScroll : function(){
550 var mb = this.scroller.dom;
551 this.innerHd.scrollLeft = mb.scrollLeft;
552 this.innerHd.scrollLeft = mb.scrollLeft; // second time for IE (1/2 time first fails, other browsers ignore)
556 updateSortIcon : function(col, dir){
557 var sc = this.sortClasses;
558 var hds = this.mainHd.select('td').removeClass(sc);
559 hds.item(col).addClass(sc[dir == 'DESC' ? 1 : 0]);
563 updateAllColumnWidths : function(){
564 var tw = this.getTotalWidth(),
565 clen = this.cm.getColumnCount(),
569 for(i = 0; i < clen; i++){
570 ws[i] = this.getColumnWidth(i);
572 this.innerHd.firstChild.style.width = this.getOffsetWidth();
573 this.innerHd.firstChild.firstChild.style.width = tw;
574 this.mainBody.dom.style.width = tw;
575 for(i = 0; i < clen; i++){
576 var hd = this.getHeaderCell(i);
577 hd.style.width = ws[i];
580 var ns = this.getRows(), row, trow;
581 for(i = 0, len = ns.length; i < len; i++){
583 row.style.width = tw;
585 row.firstChild.style.width = tw;
586 trow = row.firstChild.rows[0];
587 for (var j = 0; j < clen; j++) {
588 trow.childNodes[j].style.width = ws[j];
593 this.onAllColumnWidthsUpdated(ws, tw);
597 updateColumnWidth : function(col, width){
598 var w = this.getColumnWidth(col);
599 var tw = this.getTotalWidth();
600 this.innerHd.firstChild.style.width = this.getOffsetWidth();
601 this.innerHd.firstChild.firstChild.style.width = tw;
602 this.mainBody.dom.style.width = tw;
603 var hd = this.getHeaderCell(col);
606 var ns = this.getRows(), row;
607 for(var i = 0, len = ns.length; i < len; i++){
609 row.style.width = tw;
611 row.firstChild.style.width = tw;
612 row.firstChild.rows[0].childNodes[col].style.width = w;
616 this.onColumnWidthUpdated(col, w, tw);
620 updateColumnHidden : function(col, hidden){
621 var tw = this.getTotalWidth();
622 this.innerHd.firstChild.style.width = this.getOffsetWidth();
623 this.innerHd.firstChild.firstChild.style.width = tw;
624 this.mainBody.dom.style.width = tw;
625 var display = hidden ? 'none' : '';
627 var hd = this.getHeaderCell(col);
628 hd.style.display = display;
630 var ns = this.getRows(), row;
631 for(var i = 0, len = ns.length; i < len; i++){
633 row.style.width = tw;
635 row.firstChild.style.width = tw;
636 row.firstChild.rows[0].childNodes[col].style.display = display;
640 this.onColumnHiddenUpdated(col, hidden, tw);
641 delete this.lastViewWidth; // force recalc
646 doRender : function(cs, rs, ds, startRow, colCount, stripe){
647 var ts = this.templates, ct = ts.cell, rt = ts.row, last = colCount-1;
648 var tstyle = 'width:'+this.getTotalWidth()+';';
650 var buf = [], cb, c, p = {}, rp = {tstyle: tstyle}, r;
651 for(var j = 0, len = rs.length; j < len; j++){
653 var rowIndex = (j+startRow);
654 for(var i = 0; i < colCount; i++){
657 p.css = i === 0 ? 'x-grid3-cell-first ' : (i == last ? 'x-grid3-cell-last ' : '');
658 p.attr = p.cellAttr = '';
659 p.value = c.renderer.call(c.scope, r.data[c.name], p, r, rowIndex, i, ds);
661 if(Ext.isEmpty(p.value)){
664 if(this.markDirty && r.dirty && Ext.isDefined(r.modified[c.name])){
665 p.css += ' x-grid3-dirty-cell';
667 cb[cb.length] = ct.apply(p);
670 if(stripe && ((rowIndex+1) % 2 === 0)){
671 alt[0] = 'x-grid3-row-alt';
674 alt[1] = ' x-grid3-dirty-row';
677 if(this.getRowClass){
678 alt[2] = this.getRowClass(r, rowIndex, rp, ds);
680 rp.alt = alt.join(' ');
681 rp.cells = cb.join('');
682 buf[buf.length] = rt.apply(rp);
688 processRows : function(startRow, skipStripe){
689 if(!this.ds || this.ds.getCount() < 1){
692 var rows = this.getRows(),
696 skipStripe = skipStripe || !this.grid.stripeRows;
697 startRow = startRow || 0;
698 for(i = 0; i<len; i++) {
703 r.className = r.className.replace(this.rowClsRe, ' ');
704 if ((i + 1) % 2 === 0){
705 r.className += ' x-grid3-row-alt';
710 // add first/last-row classes
712 Ext.fly(rows[0]).addClass(this.firstRowCls);
714 Ext.fly(rows[rows.length - 1]).addClass(this.lastRowCls);
717 afterRender : function(){
718 if(!this.ds || !this.cm){
721 this.mainBody.dom.innerHTML = this.renderRows() || ' ';
722 this.processRows(0, true);
724 if(this.deferEmptyText !== true){
725 this.applyEmptyText();
727 this.grid.fireEvent('viewready', this.grid);
731 renderUI : function(){
733 var header = this.renderHeaders();
734 var body = this.templates.body.apply({rows:' '});
737 var html = this.templates.master.apply({
740 ostyle: 'width:'+this.getOffsetWidth()+';',
741 bstyle: 'width:'+this.getTotalWidth()+';'
746 g.getGridEl().dom.innerHTML = html;
750 // get mousedowns early
751 Ext.fly(this.innerHd).on('click', this.handleHdDown, this);
754 mouseover: this.handleHdOver,
755 mouseout: this.handleHdOut,
756 mousemove: this.handleHdMove
759 this.scroller.on('scroll', this.syncScroll, this);
760 if(g.enableColumnResize !== false){
761 this.splitZone = new Ext.grid.GridView.SplitDragZone(g, this.mainHd.dom);
764 if(g.enableColumnMove){
765 this.columnDrag = new Ext.grid.GridView.ColumnDragZone(g, this.innerHd);
766 this.columnDrop = new Ext.grid.HeaderDropZone(g, this.mainHd.dom);
769 if(g.enableHdMenu !== false){
770 this.hmenu = new Ext.menu.Menu({id: g.id + '-hctx'});
772 {itemId:'asc', text: this.sortAscText, cls: 'xg-hmenu-sort-asc'},
773 {itemId:'desc', text: this.sortDescText, cls: 'xg-hmenu-sort-desc'}
775 if(g.enableColumnHide !== false){
776 this.colMenu = new Ext.menu.Menu({id:g.id + '-hcols-menu'});
779 beforeshow: this.beforeColMenuShow,
780 itemclick: this.handleHdMenuClick
782 this.hmenu.add('-', {
785 text: this.columnsText,
787 iconCls: 'x-cols-icon'
790 this.hmenu.on('itemclick', this.handleHdMenuClick, this);
793 if(g.trackMouseOver){
796 mouseover: this.onRowOver,
797 mouseout: this.onRowOut
801 if(g.enableDragDrop || g.enableDrag){
802 this.dragZone = new Ext.grid.GridDragZone(g, {
803 ddGroup : g.ddGroup || 'GridDD'
807 this.updateHeaderSortState();
812 processEvent: Ext.emptyFn,
817 return; // not rendered
820 var c = g.getGridEl();
821 var csize = c.getSize(true);
822 var vw = csize.width;
824 if(!g.hideHeaders && (vw < 20 || csize.height < 20)){ // display: none?
829 this.scroller.dom.style.overflow = 'visible';
831 this.scroller.dom.style.position = 'static';
834 this.el.setSize(csize.width, csize.height);
836 var hdHeight = this.mainHd.getHeight();
837 var vh = csize.height - (hdHeight);
839 this.scroller.setSize(vw, vh);
841 this.innerHd.style.width = (vw)+'px';
845 if(this.lastViewWidth != vw){
846 this.fitColumns(false, false);
847 this.lastViewWidth = vw;
851 this.syncHeaderScroll();
853 this.onLayout(vw, vh);
856 // template functions for subclasses and plugins
857 // these functions include precalculated values
858 onLayout : function(vw, vh){
862 onColumnWidthUpdated : function(col, w, tw){
866 onAllColumnWidthsUpdated : function(ws, tw){
870 onColumnHiddenUpdated : function(col, hidden, tw){
874 updateColumnText : function(col, text){
878 afterMove : function(colIndex){
882 /* ----------------------------------- Core Specific -------------------------------------------*/
884 init : function(grid){
887 this.initTemplates();
888 this.initData(grid.store, grid.colModel);
893 getColumnId : function(index){
894 return this.cm.getColumnId(index);
898 getOffsetWidth : function() {
899 return (this.cm.getTotalWidth() + this.getScrollOffset()) + 'px';
902 getScrollOffset: function(){
903 return Ext.num(this.scrollOffset, Ext.getScrollBarWidth());
907 renderHeaders : function(){
913 len = cm.getColumnCount(),
916 for(var i = 0; i < len; i++){
917 p.id = cm.getColumnId(i);
918 p.value = cm.getColumnHeader(i) || '';
919 p.style = this.getColumnStyle(i, true);
920 p.tooltip = this.getColumnTooltip(i);
921 p.css = i === 0 ? 'x-grid3-cell-first ' : (i == last ? 'x-grid3-cell-last ' : '');
922 if(cm.config[i].align == 'right'){
923 p.istyle = 'padding-right:16px';
927 cb[cb.length] = ct.apply(p);
929 return ts.header.apply({cells: cb.join(''), tstyle:'width:'+this.getTotalWidth()+';'});
933 getColumnTooltip : function(i){
934 var tt = this.cm.getColumnTooltip(i);
936 if(Ext.QuickTips.isEnabled()){
937 return 'ext:qtip="'+tt+'"';
939 return 'title="'+tt+'"';
946 beforeUpdate : function(){
947 this.grid.stopEditing(true);
951 updateHeaders : function(){
952 this.innerHd.firstChild.innerHTML = this.renderHeaders();
953 this.innerHd.firstChild.style.width = this.getOffsetWidth();
954 this.innerHd.firstChild.firstChild.style.width = this.getTotalWidth();
958 * Focuses the specified row.
959 * @param {Number} row The row index
961 focusRow : function(row){
962 this.focusCell(row, 0, false);
966 * Focuses the specified cell.
967 * @param {Number} row The row index
968 * @param {Number} col The column index
970 focusCell : function(row, col, hscroll){
971 this.syncFocusEl(this.ensureVisible(row, col, hscroll));
973 this.focusEl.focus();
975 this.focusEl.focus.defer(1, this.focusEl);
979 resolveCell : function(row, col, hscroll){
980 if(!Ext.isNumber(row)){
986 if(row < 0 || row >= this.ds.getCount()){
989 col = (col !== undefined ? col : 0);
991 var rowEl = this.getRow(row),
993 colCount = cm.getColumnCount(),
995 if(!(hscroll === false && col === 0)){
996 while(col < colCount && cm.isHidden(col)){
999 cellEl = this.getCell(row, col);
1002 return {row: rowEl, cell: cellEl};
1005 getResolvedXY : function(resolved){
1009 var s = this.scroller.dom, c = resolved.cell, r = resolved.row;
1010 return c ? Ext.fly(c).getXY() : [this.el.getX(), Ext.fly(r).getY()];
1013 syncFocusEl : function(row, col, hscroll){
1015 if(!Ext.isArray(xy)){
1016 row = Math.min(row, Math.max(0, this.getRows().length-1));
1017 xy = this.getResolvedXY(this.resolveCell(row, col, hscroll));
1019 this.focusEl.setXY(xy||this.scroller.getXY());
1022 ensureVisible : function(row, col, hscroll){
1023 var resolved = this.resolveCell(row, col, hscroll);
1024 if(!resolved || !resolved.row){
1028 var rowEl = resolved.row,
1029 cellEl = resolved.cell,
1030 c = this.scroller.dom,
1035 while(p && p != stop){
1036 ctop += p.offsetTop;
1040 ctop -= this.mainHd.dom.offsetHeight;
1041 stop = parseInt(c.scrollTop, 10);
1043 var cbot = ctop + rowEl.offsetHeight,
1044 ch = c.clientHeight,
1050 }else if(cbot > sbot){
1051 c.scrollTop = cbot-ch;
1054 if(hscroll !== false){
1055 var cleft = parseInt(cellEl.offsetLeft, 10);
1056 var cright = cleft + cellEl.offsetWidth;
1058 var sleft = parseInt(c.scrollLeft, 10);
1059 var sright = sleft + c.clientWidth;
1061 c.scrollLeft = cleft;
1062 }else if(cright > sright){
1063 c.scrollLeft = cright-c.clientWidth;
1066 return this.getResolvedXY(resolved);
1070 insertRows : function(dm, firstRow, lastRow, isUpdate){
1071 var last = dm.getCount() - 1;
1072 if(!isUpdate && firstRow === 0 && lastRow >= last){
1073 this.fireEvent('beforerowsinserted', this, firstRow, lastRow);
1075 this.fireEvent('rowsinserted', this, firstRow, lastRow);
1078 this.fireEvent('beforerowsinserted', this, firstRow, lastRow);
1080 var html = this.renderRows(firstRow, lastRow),
1081 before = this.getRow(firstRow);
1084 Ext.fly(this.getRow(0)).removeClass(this.firstRowCls);
1086 Ext.DomHelper.insertHtml('beforeBegin', before, html);
1088 var r = this.getRow(last - 1);
1090 Ext.fly(r).removeClass(this.lastRowCls);
1092 Ext.DomHelper.insertHtml('beforeEnd', this.mainBody.dom, html);
1095 this.fireEvent('rowsinserted', this, firstRow, lastRow);
1096 this.processRows(firstRow);
1097 }else if(firstRow === 0 || firstRow >= last){
1098 //ensure first/last row is kept after an update.
1099 Ext.fly(this.getRow(firstRow)).addClass(firstRow === 0 ? this.firstRowCls : this.lastRowCls);
1102 this.syncFocusEl(firstRow);
1106 deleteRows : function(dm, firstRow, lastRow){
1107 if(dm.getRowCount()<1){
1110 this.fireEvent('beforerowsdeleted', this, firstRow, lastRow);
1112 this.removeRows(firstRow, lastRow);
1114 this.processRows(firstRow);
1115 this.fireEvent('rowsdeleted', this, firstRow, lastRow);
1120 getColumnStyle : function(col, isHeader){
1121 var style = !isHeader ? (this.cm.config[col].css || '') : '';
1122 style += 'width:'+this.getColumnWidth(col)+';';
1123 if(this.cm.isHidden(col)){
1124 style += 'display:none;';
1126 var align = this.cm.config[col].align;
1128 style += 'text-align:'+align+';';
1134 getColumnWidth : function(col){
1135 var w = this.cm.getColumnWidth(col);
1136 if(Ext.isNumber(w)){
1137 return (Ext.isBorderBox || (Ext.isWebKit && !Ext.isSafari2) ? w : (w - this.borderWidth > 0 ? w - this.borderWidth : 0)) + 'px';
1143 getTotalWidth : function(){
1144 return this.cm.getTotalWidth()+'px';
1148 fitColumns : function(preventRefresh, onlyExpand, omitColumn){
1149 var cm = this.cm, i;
1150 var tw = cm.getTotalWidth(false);
1151 var aw = this.grid.getGridEl().getWidth(true)-this.getScrollOffset();
1153 if(aw < 20){ // not initialized, so don't screw up the default widths
1156 var extra = aw - tw;
1162 var vc = cm.getColumnCount(true);
1163 var ac = vc-(Ext.isNumber(omitColumn) ? 1 : 0);
1166 omitColumn = undefined;
1168 var colCount = cm.getColumnCount();
1173 for (i = 0; i < colCount; i++){
1174 if(!cm.isHidden(i) && !cm.isFixed(i) && i !== omitColumn){
1175 w = cm.getColumnWidth(i);
1182 var frac = (aw - cm.getTotalWidth())/width;
1183 while (cols.length){
1186 cm.setColumnWidth(i, Math.max(this.grid.minColumnWidth, Math.floor(w + w*frac)), true);
1189 if((tw = cm.getTotalWidth(false)) > aw){
1190 var adjustCol = ac != vc ? omitColumn : extraCol;
1191 cm.setColumnWidth(adjustCol, Math.max(1,
1192 cm.getColumnWidth(adjustCol)- (tw-aw)), true);
1195 if(preventRefresh !== true){
1196 this.updateAllColumnWidths();
1204 autoExpand : function(preventUpdate){
1205 var g = this.grid, cm = this.cm;
1206 if(!this.userResized && g.autoExpandColumn){
1207 var tw = cm.getTotalWidth(false);
1208 var aw = this.grid.getGridEl().getWidth(true)-this.getScrollOffset();
1210 var ci = cm.getIndexById(g.autoExpandColumn);
1211 var currentWidth = cm.getColumnWidth(ci);
1212 var cw = Math.min(Math.max(((aw-tw)+currentWidth), g.autoExpandMin), g.autoExpandMax);
1213 if(cw != currentWidth){
1214 cm.setColumnWidth(ci, cw, true);
1215 if(preventUpdate !== true){
1216 this.updateColumnWidth(ci, cw);
1224 getColumnData : function(){
1225 // build a map for all the columns
1226 var cs = [], cm = this.cm, colCount = cm.getColumnCount();
1227 for(var i = 0; i < colCount; i++){
1228 var name = cm.getDataIndex(i);
1230 name : (!Ext.isDefined(name) ? this.ds.fields.get(i).name : name),
1231 renderer : cm.getRenderer(i),
1232 scope: cm.getRendererScope(i),
1233 id : cm.getColumnId(i),
1234 style : this.getColumnStyle(i)
1241 renderRows : function(startRow, endRow){
1242 // pull in all the crap needed to render rows
1243 var g = this.grid, cm = g.colModel, ds = g.store, stripe = g.stripeRows;
1244 var colCount = cm.getColumnCount();
1246 if(ds.getCount() < 1){
1250 var cs = this.getColumnData();
1252 startRow = startRow || 0;
1253 endRow = !Ext.isDefined(endRow) ? ds.getCount()-1 : endRow;
1255 // records to render
1256 var rs = ds.getRange(startRow, endRow);
1258 return this.doRender(cs, rs, ds, startRow, colCount, stripe);
1262 renderBody : function(){
1263 var markup = this.renderRows() || ' ';
1264 return this.templates.body.apply({rows: markup});
1268 refreshRow : function(record){
1269 var ds = this.ds, index;
1270 if(Ext.isNumber(record)){
1272 record = ds.getAt(index);
1277 index = ds.indexOf(record);
1282 this.insertRows(ds, index, index, true);
1283 this.getRow(index).rowIndex = index;
1284 this.onRemove(ds, record, index+1, true);
1285 this.fireEvent('rowupdated', this, index, record);
1289 * Refreshs the grid UI
1290 * @param {Boolean} headersToo (optional) True to also refresh the headers
1292 refresh : function(headersToo){
1293 this.fireEvent('beforerefresh', this);
1294 this.grid.stopEditing(true);
1296 var result = this.renderBody();
1297 this.mainBody.update(result).setWidth(this.getTotalWidth());
1298 if(headersToo === true){
1299 this.updateHeaders();
1300 this.updateHeaderSortState();
1302 this.processRows(0, true);
1304 this.applyEmptyText();
1305 this.fireEvent('refresh', this);
1309 applyEmptyText : function(){
1310 if(this.emptyText && !this.hasRows()){
1311 this.mainBody.update('<div class="x-grid-empty">' + this.emptyText + '</div>');
1316 updateHeaderSortState : function(){
1317 var state = this.ds.getSortState();
1321 if(!this.sortState || (this.sortState.field != state.field || this.sortState.direction != state.direction)){
1322 this.grid.fireEvent('sortchange', this.grid, state);
1324 this.sortState = state;
1325 var sortColumn = this.cm.findColumnIndex(state.field);
1326 if(sortColumn != -1){
1327 var sortDir = state.direction;
1328 this.updateSortIcon(sortColumn, sortDir);
1333 clearHeaderSortState : function(){
1334 if(!this.sortState){
1337 this.grid.fireEvent('sortchange', this.grid, null);
1338 this.mainHd.select('td').removeClass(this.sortClasses);
1339 delete this.sortState;
1343 destroy : function(){
1345 Ext.menu.MenuMgr.unregister(this.colMenu);
1346 this.colMenu.destroy();
1347 delete this.colMenu;
1350 Ext.menu.MenuMgr.unregister(this.hmenu);
1351 this.hmenu.destroy();
1355 this.initData(null, null);
1356 this.purgeListeners();
1357 Ext.fly(this.innerHd).un("click", this.handleHdDown, this);
1359 if(this.grid.enableColumnMove){
1362 this.columnDrag.proxy.ghost,
1363 this.columnDrag.proxy.el,
1365 this.columnDrop.proxyTop,
1366 this.columnDrop.proxyBottom,
1367 this.columnDrag.dragData.ddel,
1368 this.columnDrag.dragData.header
1370 if (this.columnDrag.proxy.anim) {
1371 Ext.destroy(this.columnDrag.proxy.anim);
1373 delete this.columnDrag.proxy.ghost;
1374 delete this.columnDrag.dragData.ddel;
1375 delete this.columnDrag.dragData.header;
1376 this.columnDrag.destroy();
1377 delete Ext.dd.DDM.locationCache[this.columnDrag.id];
1378 delete this.columnDrag._domRef;
1380 delete this.columnDrop.proxyTop;
1381 delete this.columnDrop.proxyBottom;
1382 this.columnDrop.destroy();
1383 delete Ext.dd.DDM.locationCache["gridHeader" + this.grid.getGridEl().id];
1384 delete this.columnDrop._domRef;
1385 delete Ext.dd.DDM.ids[this.columnDrop.ddGroup];
1388 if (this.splitZone){ // enableColumnResize
1389 this.splitZone.destroy();
1390 delete this.splitZone._domRef;
1391 delete Ext.dd.DDM.ids["gridSplitters" + this.grid.getGridEl().id];
1394 Ext.fly(this.innerHd).removeAllListeners();
1395 Ext.removeNode(this.innerHd);
1396 delete this.innerHd;
1413 delete this.grid.container;
1416 this.dragZone.destroy();
1419 Ext.dd.DDM.currentTarget = null;
1420 delete Ext.dd.DDM.locationCache[this.grid.getGridEl().id];
1422 Ext.EventManager.removeResizeListener(this.onWindowResize, this);
1426 onDenyColumnHide : function(){
1431 render : function(){
1433 var ct = this.grid.ownerCt;
1434 if (ct && ct.getLayout()){
1435 ct.on('afterlayout', function(){
1436 this.fitColumns(true, true);
1437 this.updateHeaders();
1438 }, this, {single: true});
1440 this.fitColumns(true, true);
1442 }else if(this.forceFit){
1443 this.fitColumns(true, false);
1444 }else if(this.grid.autoExpandColumn){
1445 this.autoExpand(true);
1451 /* --------------------------------- Model Events and Handlers --------------------------------*/
1453 initData : function(ds, cm){
1455 this.ds.un('load', this.onLoad, this);
1456 this.ds.un('datachanged', this.onDataChange, this);
1457 this.ds.un('add', this.onAdd, this);
1458 this.ds.un('remove', this.onRemove, this);
1459 this.ds.un('update', this.onUpdate, this);
1460 this.ds.un('clear', this.onClear, this);
1461 if(this.ds !== ds && this.ds.autoDestroy){
1469 datachanged: this.onDataChange,
1471 remove: this.onRemove,
1472 update: this.onUpdate,
1479 this.cm.un('configchange', this.onColConfigChange, this);
1480 this.cm.un('widthchange', this.onColWidthChange, this);
1481 this.cm.un('headerchange', this.onHeaderChange, this);
1482 this.cm.un('hiddenchange', this.onHiddenChange, this);
1483 this.cm.un('columnmoved', this.onColumnMove, this);
1486 delete this.lastViewWidth;
1489 configchange: this.onColConfigChange,
1490 widthchange: this.onColWidthChange,
1491 headerchange: this.onHeaderChange,
1492 hiddenchange: this.onHiddenChange,
1493 columnmoved: this.onColumnMove
1500 onDataChange : function(){
1502 this.updateHeaderSortState();
1503 this.syncFocusEl(0);
1507 onClear : function(){
1509 this.syncFocusEl(0);
1513 onUpdate : function(ds, record){
1514 this.refreshRow(record);
1518 onAdd : function(ds, records, index){
1520 this.insertRows(ds, index, index + (records.length-1));
1524 onRemove : function(ds, record, index, isUpdate){
1525 if(isUpdate !== true){
1526 this.fireEvent('beforerowremoved', this, index, record);
1528 this.removeRow(index);
1529 if(isUpdate !== true){
1530 this.processRows(index);
1531 this.applyEmptyText();
1532 this.fireEvent('rowremoved', this, index, record);
1537 onLoad : function(){
1538 this.scrollToTop.defer(Ext.isGecko ? 1 : 0, this);
1542 onColWidthChange : function(cm, col, width){
1543 this.updateColumnWidth(col, width);
1547 onHeaderChange : function(cm, col, text){
1548 this.updateHeaders();
1552 onHiddenChange : function(cm, col, hidden){
1553 this.updateColumnHidden(col, hidden);
1557 onColumnMove : function(cm, oldIndex, newIndex){
1558 this.indexMap = null;
1559 var s = this.getScrollState();
1561 this.restoreScroll(s);
1562 this.afterMove(newIndex);
1563 this.grid.fireEvent('columnmove', oldIndex, newIndex);
1567 onColConfigChange : function(){
1568 delete this.lastViewWidth;
1569 this.indexMap = null;
1573 /* -------------------- UI Events and Handlers ------------------------------ */
1575 initUI : function(grid){
1576 grid.on('headerclick', this.onHeaderClick, this);
1580 initEvents : function(){
1584 onHeaderClick : function(g, index){
1585 if(this.headersDisabled || !this.cm.isSortable(index)){
1588 g.stopEditing(true);
1589 g.store.sort(this.cm.getDataIndex(index));
1593 onRowOver : function(e, t){
1595 if((row = this.findRowIndex(t)) !== false){
1596 this.addRowClass(row, 'x-grid3-row-over');
1601 onRowOut : function(e, t){
1603 if((row = this.findRowIndex(t)) !== false && !e.within(this.getRow(row), true)){
1604 this.removeRowClass(row, 'x-grid3-row-over');
1609 handleWheel : function(e){
1610 e.stopPropagation();
1614 onRowSelect : function(row){
1615 this.addRowClass(row, this.selectedRowClass);
1619 onRowDeselect : function(row){
1620 this.removeRowClass(row, this.selectedRowClass);
1624 onCellSelect : function(row, col){
1625 var cell = this.getCell(row, col);
1627 this.fly(cell).addClass('x-grid3-cell-selected');
1632 onCellDeselect : function(row, col){
1633 var cell = this.getCell(row, col);
1635 this.fly(cell).removeClass('x-grid3-cell-selected');
1640 onColumnSplitterMoved : function(i, w){
1641 this.userResized = true;
1642 var cm = this.grid.colModel;
1643 cm.setColumnWidth(i, w, true);
1646 this.fitColumns(true, false, i);
1647 this.updateAllColumnWidths();
1649 this.updateColumnWidth(i, w);
1650 this.syncHeaderScroll();
1653 this.grid.fireEvent('columnresize', i, w);
1657 handleHdMenuClick : function(item){
1658 var index = this.hdCtxIndex,
1661 id = item.getItemId();
1664 ds.sort(cm.getDataIndex(index), 'ASC');
1667 ds.sort(cm.getDataIndex(index), 'DESC');
1670 index = cm.getIndexById(id.substr(4));
1672 if(item.checked && cm.getColumnsBy(this.isHideableColumn, this).length <= 1){
1673 this.onDenyColumnHide();
1676 cm.setHidden(index, item.checked);
1683 isHideableColumn : function(c){
1684 return !c.hidden && !c.fixed;
1688 beforeColMenuShow : function(){
1689 var cm = this.cm, colCount = cm.getColumnCount();
1690 this.colMenu.removeAll();
1691 for(var i = 0; i < colCount; i++){
1692 if(cm.config[i].fixed !== true && cm.config[i].hideable !== false){
1693 this.colMenu.add(new Ext.menu.CheckItem({
1694 itemId: 'col-'+cm.getColumnId(i),
1695 text: cm.getColumnHeader(i),
1696 checked: !cm.isHidden(i),
1698 disabled: cm.config[i].hideable === false
1705 handleHdDown : function(e, t){
1706 if(Ext.fly(t).hasClass('x-grid3-hd-btn')){
1708 var hd = this.findHeaderCell(t);
1709 Ext.fly(hd).addClass('x-grid3-hd-menu-open');
1710 var index = this.getCellIndex(hd);
1711 this.hdCtxIndex = index;
1712 var ms = this.hmenu.items, cm = this.cm;
1713 ms.get('asc').setDisabled(!cm.isSortable(index));
1714 ms.get('desc').setDisabled(!cm.isSortable(index));
1715 this.hmenu.on('hide', function(){
1716 Ext.fly(hd).removeClass('x-grid3-hd-menu-open');
1717 }, this, {single:true});
1718 this.hmenu.show(t, 'tl-bl?');
1723 handleHdOver : function(e, t){
1724 var hd = this.findHeaderCell(t);
1725 if(hd && !this.headersDisabled){
1726 this.activeHdRef = t;
1727 this.activeHdIndex = this.getCellIndex(hd);
1728 var fly = this.fly(hd);
1729 this.activeHdRegion = fly.getRegion();
1730 if(!this.cm.isMenuDisabled(this.activeHdIndex)){
1731 fly.addClass('x-grid3-hd-over');
1732 this.activeHdBtn = fly.child('.x-grid3-hd-btn');
1733 if(this.activeHdBtn){
1734 this.activeHdBtn.dom.style.height = (hd.firstChild.offsetHeight-1)+'px';
1741 handleHdMove : function(e, t){
1742 var hd = this.findHeaderCell(this.activeHdRef);
1743 if(hd && !this.headersDisabled){
1744 var hw = this.splitHandleWidth || 5,
1745 r = this.activeHdRegion,
1749 if(this.grid.enableColumnResize !== false){
1750 if(x - r.left <= hw && this.cm.isResizable(this.activeHdIndex-1)){
1751 cur = Ext.isAir ? 'move' : Ext.isWebKit ? 'e-resize' : 'col-resize'; // col-resize not always supported
1752 }else if(r.right - x <= (!this.activeHdBtn ? hw : 2) && this.cm.isResizable(this.activeHdIndex)){
1753 cur = Ext.isAir ? 'move' : Ext.isWebKit ? 'w-resize' : 'col-resize';
1761 handleHdOut : function(e, t){
1762 var hd = this.findHeaderCell(t);
1763 if(hd && (!Ext.isIE || !e.within(hd, true))){
1764 this.activeHdRef = null;
1765 this.fly(hd).removeClass('x-grid3-hd-over');
1766 hd.style.cursor = '';
1771 hasRows : function(){
1772 var fc = this.mainBody.dom.firstChild;
1773 return fc && fc.nodeType == 1 && fc.className != 'x-grid-empty';
1777 bind : function(d, c){
1778 this.initData(d, c);
1784 // This is a support class used internally by the Grid components
1785 Ext.grid.GridView.SplitDragZone = function(grid, hd){
1787 this.view = grid.getView();
1788 this.marker = this.view.resizeMarker;
1789 this.proxy = this.view.resizeProxy;
1790 Ext.grid.GridView.SplitDragZone.superclass.constructor.call(this, hd,
1791 'gridSplitters' + this.grid.getGridEl().id, {
1792 dragElId : Ext.id(this.proxy.dom), resizeFrame:false
1794 this.scroll = false;
1795 this.hw = this.view.splitHandleWidth || 5;
1797 Ext.extend(Ext.grid.GridView.SplitDragZone, Ext.dd.DDProxy, {
1799 b4StartDrag : function(x, y){
1800 this.view.headersDisabled = true;
1801 var h = this.view.mainWrap.getHeight();
1802 this.marker.setHeight(h);
1804 this.marker.alignTo(this.view.getHeaderCell(this.cellIndex), 'tl-tl', [-2, 0]);
1805 this.proxy.setHeight(h);
1806 var w = this.cm.getColumnWidth(this.cellIndex);
1807 var minw = Math.max(w-this.grid.minColumnWidth, 0);
1808 this.resetConstraints();
1809 this.setXConstraint(minw, 1000);
1810 this.setYConstraint(0, 0);
1811 this.minX = x - minw;
1812 this.maxX = x + 1000;
1814 Ext.dd.DDProxy.prototype.b4StartDrag.call(this, x, y);
1817 allowHeaderDrag : function(e){
1822 handleMouseDown : function(e){
1823 var t = this.view.findHeaderCell(e.getTarget());
1824 if(t && this.allowHeaderDrag(e)){
1825 var xy = this.view.fly(t).getXY(), x = xy[0], y = xy[1];
1826 var exy = e.getXY(), ex = exy[0];
1827 var w = t.offsetWidth, adjust = false;
1828 if((ex - x) <= this.hw){
1830 }else if((x+w) - ex <= this.hw){
1833 if(adjust !== false){
1834 this.cm = this.grid.colModel;
1835 var ci = this.view.getCellIndex(t);
1837 if (ci + adjust < 0) {
1840 while(this.cm.isHidden(ci+adjust)){
1847 this.cellIndex = ci+adjust;
1849 if(this.cm.isResizable(this.cellIndex) && !this.cm.isFixed(this.cellIndex)){
1850 Ext.grid.GridView.SplitDragZone.superclass.handleMouseDown.apply(this, arguments);
1852 }else if(this.view.columnDrag){
1853 this.view.columnDrag.callHandleMouseDown(e);
1858 endDrag : function(e){
1861 var endX = Math.max(this.minX, e.getPageX());
1862 var diff = endX - this.startPos;
1863 v.onColumnSplitterMoved(this.cellIndex, this.cm.getColumnWidth(this.cellIndex)+diff);
1864 setTimeout(function(){
1865 v.headersDisabled = false;
1869 autoOffset : function(){