3 * Copyright(c) 2006-2010 Sencha Inc.
5 * http://www.sencha.com/license
9 * Copyright(c) 2006-2010 Ext JS, Inc.
11 * http://www.extjs.com/license
13 Ext.ns('Ext.ux.grid');
15 Ext.ux.grid.LockingGridView = Ext.extend(Ext.grid.GridView, {
17 unlockText : 'Unlock',
19 lockedBorderWidth : 1,
22 * This option ensures that height between the rows is synchronized
23 * between the locked and unlocked sides. This option only needs to be used
24 * when the row heights aren't predictable.
28 initTemplates : function(){
29 var ts = this.templates || {};
32 ts.masterTpl = new Ext.Template(
33 '<div class="x-grid3" hidefocus="true">',
34 '<div class="x-grid3-locked">',
35 '<div class="x-grid3-header"><div class="x-grid3-header-inner"><div class="x-grid3-header-offset" style="{lstyle}">{lockedHeader}</div></div><div class="x-clear"></div></div>',
36 '<div class="x-grid3-scroller"><div class="x-grid3-body" style="{lstyle}">{lockedBody}</div><div class="x-grid3-scroll-spacer"></div></div>',
38 '<div class="x-grid3-viewport x-grid3-unlocked">',
39 '<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>',
40 '<div class="x-grid3-scroller"><div class="x-grid3-body" style="{bstyle}">{body}</div><a href="#" class="x-grid3-focus" tabIndex="-1"></a></div>',
42 '<div class="x-grid3-resize-marker"> </div>',
43 '<div class="x-grid3-resize-proxy"> </div>',
50 Ext.ux.grid.LockingGridView.superclass.initTemplates.call(this);
53 getEditorParent : function(ed){
57 initElements : function(){
58 var el = Ext.get(this.grid.getGridEl().dom.firstChild),
59 lockedWrap = el.child('div.x-grid3-locked'),
60 lockedHd = lockedWrap.child('div.x-grid3-header'),
61 lockedScroller = lockedWrap.child('div.x-grid3-scroller'),
62 mainWrap = el.child('div.x-grid3-viewport'),
63 mainHd = mainWrap.child('div.x-grid3-header'),
64 scroller = mainWrap.child('div.x-grid3-scroller');
66 if (this.grid.hideHeaders) {
67 lockedHd.setDisplayed(false);
68 mainHd.setDisplayed(false);
72 scroller.setStyle('overflow-x', 'hidden');
79 innerHd : mainHd.dom.firstChild,
81 mainBody: scroller.child('div.x-grid3-body'),
82 focusEl : scroller.child('a'),
83 resizeMarker: el.child('div.x-grid3-resize-marker'),
84 resizeProxy : el.child('div.x-grid3-resize-proxy'),
85 lockedWrap: lockedWrap,
87 lockedScroller: lockedScroller,
88 lockedBody: lockedScroller.child('div.x-grid3-body'),
89 lockedInnerHd: lockedHd.child('div.x-grid3-header-inner', true)
92 this.focusEl.swallowEvent('click', true);
95 getLockedRows : function(){
96 return this.hasRows() ? this.lockedBody.dom.childNodes : [];
99 getLockedRow : function(row){
100 return this.getLockedRows()[row];
103 getCell : function(row, col){
104 var lockedLen = this.cm.getLockedCount();
106 return this.getLockedRow(row).getElementsByTagName('td')[col];
108 return Ext.ux.grid.LockingGridView.superclass.getCell.call(this, row, col - lockedLen);
111 getHeaderCell : function(index){
112 var lockedLen = this.cm.getLockedCount();
113 if(index < lockedLen){
114 return this.lockedHd.dom.getElementsByTagName('td')[index];
116 return Ext.ux.grid.LockingGridView.superclass.getHeaderCell.call(this, index - lockedLen);
119 addRowClass : function(row, cls){
120 var lockedRow = this.getLockedRow(row);
122 this.fly(lockedRow).addClass(cls);
124 Ext.ux.grid.LockingGridView.superclass.addRowClass.call(this, row, cls);
127 removeRowClass : function(row, cls){
128 var lockedRow = this.getLockedRow(row);
130 this.fly(lockedRow).removeClass(cls);
132 Ext.ux.grid.LockingGridView.superclass.removeRowClass.call(this, row, cls);
135 removeRow : function(row) {
136 Ext.removeNode(this.getLockedRow(row));
137 Ext.ux.grid.LockingGridView.superclass.removeRow.call(this, row);
140 removeRows : function(firstRow, lastRow){
141 var lockedBody = this.lockedBody.dom,
143 for(; rowIndex <= lastRow; rowIndex++){
144 Ext.removeNode(lockedBody.childNodes[firstRow]);
146 Ext.ux.grid.LockingGridView.superclass.removeRows.call(this, firstRow, lastRow);
149 syncScroll : function(e){
150 this.lockedScroller.dom.scrollTop = this.scroller.dom.scrollTop;
151 Ext.ux.grid.LockingGridView.superclass.syncScroll.call(this, e);
154 updateSortIcon : function(col, dir){
155 var sortClasses = this.sortClasses,
156 lockedHeaders = this.lockedHd.select('td').removeClass(sortClasses),
157 headers = this.mainHd.select('td').removeClass(sortClasses),
158 lockedLen = this.cm.getLockedCount(),
159 cls = sortClasses[dir == 'DESC' ? 1 : 0];
162 lockedHeaders.item(col).addClass(cls);
164 headers.item(col - lockedLen).addClass(cls);
168 updateAllColumnWidths : function(){
169 var tw = this.getTotalWidth(),
170 clen = this.cm.getColumnCount(),
171 lw = this.getLockedWidth(),
172 llen = this.cm.getLockedCount(),
174 this.updateLockedWidth();
175 for(i = 0; i < clen; i++){
176 ws[i] = this.getColumnWidth(i);
177 var hd = this.getHeaderCell(i);
178 hd.style.width = ws[i];
180 var lns = this.getLockedRows(), ns = this.getRows(), row, trow, j;
181 for(i = 0, len = ns.length; i < len; i++){
183 row.style.width = lw;
185 row.firstChild.style.width = lw;
186 trow = row.firstChild.rows[0];
187 for (j = 0; j < llen; j++) {
188 trow.childNodes[j].style.width = ws[j];
192 row.style.width = tw;
194 row.firstChild.style.width = tw;
195 trow = row.firstChild.rows[0];
196 for (j = llen; j < clen; j++) {
197 trow.childNodes[j - llen].style.width = ws[j];
201 this.onAllColumnWidthsUpdated(ws, tw);
202 this.syncHeaderHeight();
205 updateColumnWidth : function(col, width){
206 var w = this.getColumnWidth(col),
207 llen = this.cm.getLockedCount(),
209 this.updateLockedWidth();
211 ns = this.getLockedRows();
212 rw = this.getLockedWidth();
216 rw = this.getTotalWidth();
219 var hd = this.getHeaderCell(col);
221 for(var i = 0, len = ns.length; i < len; i++){
223 row.style.width = rw;
225 row.firstChild.style.width = rw;
226 row.firstChild.rows[0].childNodes[c].style.width = w;
229 this.onColumnWidthUpdated(col, w, this.getTotalWidth());
230 this.syncHeaderHeight();
233 updateColumnHidden : function(col, hidden){
234 var llen = this.cm.getLockedCount(),
236 display = hidden ? 'none' : '';
237 this.updateLockedWidth();
239 ns = this.getLockedRows();
240 rw = this.getLockedWidth();
244 rw = this.getTotalWidth();
247 var hd = this.getHeaderCell(col);
248 hd.style.display = display;
249 for(var i = 0, len = ns.length; i < len; i++){
251 row.style.width = rw;
253 row.firstChild.style.width = rw;
254 row.firstChild.rows[0].childNodes[c].style.display = display;
257 this.onColumnHiddenUpdated(col, hidden, this.getTotalWidth());
258 delete this.lastViewWidth;
262 doRender : function(cs, rs, ds, startRow, colCount, stripe){
263 var ts = this.templates, ct = ts.cell, rt = ts.row, last = colCount-1,
264 tstyle = 'width:'+this.getTotalWidth()+';',
265 lstyle = 'width:'+this.getLockedWidth()+';',
266 buf = [], lbuf = [], cb, lcb, c, p = {}, rp = {}, r;
267 for(var j = 0, len = rs.length; j < len; j++){
268 r = rs[j]; cb = []; lcb = [];
269 var rowIndex = (j+startRow);
270 for(var i = 0; i < colCount; i++){
273 p.css = (i === 0 ? 'x-grid3-cell-first ' : (i == last ? 'x-grid3-cell-last ' : '')) +
274 (this.cm.config[i].cellCls ? ' ' + this.cm.config[i].cellCls : '');
275 p.attr = p.cellAttr = '';
276 p.value = c.renderer(r.data[c.name], p, r, rowIndex, i, ds);
278 if(Ext.isEmpty(p.value)){
281 if(this.markDirty && r.dirty && Ext.isDefined(r.modified[c.name])){
282 p.css += ' x-grid3-dirty-cell';
285 lcb[lcb.length] = ct.apply(p);
287 cb[cb.length] = ct.apply(p);
291 if(stripe && ((rowIndex+1) % 2 === 0)){
292 alt[0] = 'x-grid3-row-alt';
295 alt[1] = ' x-grid3-dirty-row';
298 if(this.getRowClass){
299 alt[2] = this.getRowClass(r, rowIndex, rp, ds);
301 rp.alt = alt.join(' ');
302 rp.cells = cb.join('');
304 buf[buf.length] = rt.apply(rp);
305 rp.cells = lcb.join('');
307 lbuf[lbuf.length] = rt.apply(rp);
309 return [buf.join(''), lbuf.join('')];
311 processRows : function(startRow, skipStripe){
312 if(!this.ds || this.ds.getCount() < 1){
315 var rows = this.getRows(),
316 lrows = this.getLockedRows(),
318 skipStripe = skipStripe || !this.grid.stripeRows;
319 startRow = startRow || 0;
320 for(var i = 0, len = rows.length; i < len; ++i){
326 row.className = row.className.replace(this.rowClsRe, ' ');
327 lrow.className = lrow.className.replace(this.rowClsRe, ' ');
328 if ((i + 1) % 2 === 0){
329 row.className += ' x-grid3-row-alt';
330 lrow.className += ' x-grid3-row-alt';
333 this.syncRowHeights(row, lrow);
336 Ext.fly(rows[0]).addClass(this.firstRowCls);
337 Ext.fly(lrows[0]).addClass(this.firstRowCls);
339 Ext.fly(rows[rows.length - 1]).addClass(this.lastRowCls);
340 Ext.fly(lrows[lrows.length - 1]).addClass(this.lastRowCls);
343 syncRowHeights: function(row1, row2){
344 if(this.syncHeights){
345 var el1 = Ext.get(row1),
347 h1 = el1.getHeight(),
348 h2 = el2.getHeight();
358 afterRender : function(){
359 if(!this.ds || !this.cm){
362 var bd = this.renderRows() || [' ', ' '];
363 this.mainBody.dom.innerHTML = bd[0];
364 this.lockedBody.dom.innerHTML = bd[1];
365 this.processRows(0, true);
366 if(this.deferEmptyText !== true){
367 this.applyEmptyText();
369 this.grid.fireEvent('viewready', this.grid);
372 renderUI : function(){
373 var templates = this.templates,
374 header = this.renderHeaders(),
375 body = templates.body.apply({rows:' '});
377 return templates.masterTpl.apply({
380 ostyle: 'width:' + this.getOffsetWidth() + ';',
381 bstyle: 'width:' + this.getTotalWidth() + ';',
383 lockedHeader: header[1],
384 lstyle: 'width:'+this.getLockedWidth()+';'
388 afterRenderUI: function(){
391 Ext.fly(this.innerHd).on('click', this.handleHdDown, this);
392 Ext.fly(this.lockedInnerHd).on('click', this.handleHdDown, this);
395 mouseover: this.handleHdOver,
396 mouseout: this.handleHdOut,
397 mousemove: this.handleHdMove
401 mouseover: this.handleHdOver,
402 mouseout: this.handleHdOut,
403 mousemove: this.handleHdMove
405 this.scroller.on('scroll', this.syncScroll, this);
406 if(g.enableColumnResize !== false){
407 this.splitZone = new Ext.grid.GridView.SplitDragZone(g, this.mainHd.dom);
408 this.splitZone.setOuterHandleElId(Ext.id(this.lockedHd.dom));
409 this.splitZone.setOuterHandleElId(Ext.id(this.mainHd.dom));
411 if(g.enableColumnMove){
412 this.columnDrag = new Ext.grid.GridView.ColumnDragZone(g, this.innerHd);
413 this.columnDrag.setOuterHandleElId(Ext.id(this.lockedInnerHd));
414 this.columnDrag.setOuterHandleElId(Ext.id(this.innerHd));
415 this.columnDrop = new Ext.grid.HeaderDropZone(g, this.mainHd.dom);
417 if(g.enableHdMenu !== false){
418 this.hmenu = new Ext.menu.Menu({id: g.id + '-hctx'});
420 {itemId: 'asc', text: this.sortAscText, cls: 'xg-hmenu-sort-asc'},
421 {itemId: 'desc', text: this.sortDescText, cls: 'xg-hmenu-sort-desc'}
423 if(this.grid.enableColLock !== false){
425 {itemId: 'lock', text: this.lockText, cls: 'xg-hmenu-lock'},
426 {itemId: 'unlock', text: this.unlockText, cls: 'xg-hmenu-unlock'}
429 if(g.enableColumnHide !== false){
430 this.colMenu = new Ext.menu.Menu({id:g.id + '-hcols-menu'});
433 beforeshow: this.beforeColMenuShow,
434 itemclick: this.handleHdMenuClick
436 this.hmenu.add('-', {
439 text: this.columnsText,
441 iconCls: 'x-cols-icon'
444 this.hmenu.on('itemclick', this.handleHdMenuClick, this);
446 if(g.trackMouseOver){
449 mouseover: this.onRowOver,
450 mouseout: this.onRowOut
454 mouseover: this.onRowOver,
455 mouseout: this.onRowOut
459 if(g.enableDragDrop || g.enableDrag){
460 this.dragZone = new Ext.grid.GridDragZone(g, {
461 ddGroup : g.ddGroup || 'GridDD'
464 this.updateHeaderSortState();
472 var c = g.getGridEl();
473 var csize = c.getSize(true);
474 var vw = csize.width;
475 if(!g.hideHeaders && (vw < 20 || csize.height < 20)){
478 this.syncHeaderHeight();
480 this.scroller.dom.style.overflow = 'visible';
481 this.lockedScroller.dom.style.overflow = 'visible';
483 this.scroller.dom.style.position = 'static';
484 this.lockedScroller.dom.style.position = 'static';
487 this.el.setSize(csize.width, csize.height);
488 var hdHeight = this.mainHd.getHeight();
489 var vh = csize.height - (hdHeight);
491 this.updateLockedWidth();
493 if(this.lastViewWidth != vw){
494 this.fitColumns(false, false);
495 this.lastViewWidth = vw;
499 this.syncHeaderScroll();
501 this.onLayout(vw, vh);
504 getOffsetWidth : function() {
505 return (this.cm.getTotalWidth() - this.cm.getTotalLockedWidth() + this.getScrollOffset()) + 'px';
508 renderHeaders : function(){
514 len = cm.getColumnCount(),
516 for(var i = 0; i < len; i++){
517 p.id = cm.getColumnId(i);
518 p.value = cm.getColumnHeader(i) || '';
519 p.style = this.getColumnStyle(i, true);
520 p.tooltip = this.getColumnTooltip(i);
521 p.css = (i === 0 ? 'x-grid3-cell-first ' : (i == last ? 'x-grid3-cell-last ' : '')) +
522 (cm.config[i].headerCls ? ' ' + cm.config[i].headerCls : '');
523 if(cm.config[i].align == 'right'){
524 p.istyle = 'padding-right:16px';
529 lcb[lcb.length] = ct.apply(p);
531 cb[cb.length] = ct.apply(p);
534 return [ts.header.apply({cells: cb.join(''), tstyle:'width:'+this.getTotalWidth()+';'}),
535 ts.header.apply({cells: lcb.join(''), tstyle:'width:'+this.getLockedWidth()+';'})];
538 updateHeaders : function(){
539 var hd = this.renderHeaders();
540 this.innerHd.firstChild.innerHTML = hd[0];
541 this.innerHd.firstChild.style.width = this.getOffsetWidth();
542 this.innerHd.firstChild.firstChild.style.width = this.getTotalWidth();
543 this.lockedInnerHd.firstChild.innerHTML = hd[1];
544 var lw = this.getLockedWidth();
545 this.lockedInnerHd.firstChild.style.width = lw;
546 this.lockedInnerHd.firstChild.firstChild.style.width = lw;
549 getResolvedXY : function(resolved){
553 var c = resolved.cell, r = resolved.row;
554 return c ? Ext.fly(c).getXY() : [this.scroller.getX(), Ext.fly(r).getY()];
557 syncFocusEl : function(row, col, hscroll){
558 Ext.ux.grid.LockingGridView.superclass.syncFocusEl.call(this, row, col, col < this.cm.getLockedCount() ? false : hscroll);
561 ensureVisible : function(row, col, hscroll){
562 return Ext.ux.grid.LockingGridView.superclass.ensureVisible.call(this, row, col, col < this.cm.getLockedCount() ? false : hscroll);
565 insertRows : function(dm, firstRow, lastRow, isUpdate){
566 var last = dm.getCount() - 1;
567 if(!isUpdate && firstRow === 0 && lastRow >= last){
571 this.fireEvent('beforerowsinserted', this, firstRow, lastRow);
573 var html = this.renderRows(firstRow, lastRow),
574 before = this.getRow(firstRow);
577 this.removeRowClass(0, this.firstRowCls);
579 Ext.DomHelper.insertHtml('beforeBegin', before, html[0]);
580 before = this.getLockedRow(firstRow);
581 Ext.DomHelper.insertHtml('beforeBegin', before, html[1]);
583 this.removeRowClass(last - 1, this.lastRowCls);
584 Ext.DomHelper.insertHtml('beforeEnd', this.mainBody.dom, html[0]);
585 Ext.DomHelper.insertHtml('beforeEnd', this.lockedBody.dom, html[1]);
588 this.fireEvent('rowsinserted', this, firstRow, lastRow);
589 this.processRows(firstRow);
590 }else if(firstRow === 0 || firstRow >= last){
591 this.addRowClass(firstRow, firstRow === 0 ? this.firstRowCls : this.lastRowCls);
594 this.syncFocusEl(firstRow);
597 getColumnStyle : function(col, isHeader){
598 var style = !isHeader ? this.cm.config[col].cellStyle || this.cm.config[col].css || '' : this.cm.config[col].headerStyle || '';
599 style += 'width:'+this.getColumnWidth(col)+';';
600 if(this.cm.isHidden(col)){
601 style += 'display:none;';
603 var align = this.cm.config[col].align;
605 style += 'text-align:'+align+';';
610 getLockedWidth : function() {
611 return this.cm.getTotalLockedWidth() + 'px';
614 getTotalWidth : function() {
615 return (this.cm.getTotalWidth() - this.cm.getTotalLockedWidth()) + 'px';
618 getColumnData : function(){
619 var cs = [], cm = this.cm, colCount = cm.getColumnCount();
620 for(var i = 0; i < colCount; i++){
621 var name = cm.getDataIndex(i);
623 name : (!Ext.isDefined(name) ? this.ds.fields.get(i).name : name),
624 renderer : cm.getRenderer(i),
625 id : cm.getColumnId(i),
626 style : this.getColumnStyle(i),
627 locked : cm.isLocked(i)
633 renderBody : function(){
634 var markup = this.renderRows() || [' ', ' '];
635 return [this.templates.body.apply({rows: markup[0]}), this.templates.body.apply({rows: markup[1]})];
638 refreshRow: function(record){
640 colCount = this.cm.getColumnCount(),
641 columns = this.getColumnData(),
643 cls = ['x-grid3-row'],
645 tstyle: String.format("width: {0};", this.getTotalWidth())
648 tstyle: String.format("width: {0};", this.getLockedWidth())
651 lockedColBuffer = [],
652 cellTpl = this.templates.cell,
661 if (Ext.isNumber(record)) {
663 record = store.getAt(rowIndex);
665 rowIndex = store.indexOf(record);
668 if (!record || rowIndex < 0) {
672 for (i = 0; i < colCount; i++) {
676 css = 'x-grid3-cell-first';
678 css = (i == last) ? 'x-grid3-cell-last ' : '';
689 meta.value = column.renderer.call(column.scope, record.data[column.name], meta, record, rowIndex, i, store);
691 if (Ext.isEmpty(meta.value)) {
695 if (this.markDirty && record.dirty && typeof record.modified[column.name] != 'undefined') {
696 meta.css += ' x-grid3-dirty-cell';
700 lockedColBuffer[i] = cellTpl.apply(meta);
702 colBuffer[i] = cellTpl.apply(meta);
706 row = this.getRow(rowIndex);
708 lockedRow = this.getLockedRow(rowIndex);
709 lockedRow.className = '';
711 if (this.grid.stripeRows && ((rowIndex + 1) % 2 === 0)) {
712 cls.push('x-grid3-row-alt');
715 if (this.getRowClass) {
716 rowParams.cols = colCount;
717 cls.push(this.getRowClass(record, rowIndex, rowParams, store));
721 this.fly(row).addClass(cls).setStyle(rowParams.tstyle);
722 rowParams.cells = colBuffer.join("");
723 row.innerHTML = this.templates.rowInner.apply(rowParams);
726 this.fly(lockedRow).addClass(cls).setStyle(lockedRowParams.tstyle);
727 lockedRowParams.cells = lockedColBuffer.join("");
728 lockedRow.innerHTML = this.templates.rowInner.apply(lockedRowParams);
729 lockedRow.rowIndex = rowIndex;
730 this.syncRowHeights(row, lockedRow);
731 this.fireEvent('rowupdated', this, rowIndex, record);
734 refresh : function(headersToo){
735 this.fireEvent('beforerefresh', this);
736 this.grid.stopEditing(true);
737 var result = this.renderBody();
738 this.mainBody.update(result[0]).setWidth(this.getTotalWidth());
739 this.lockedBody.update(result[1]).setWidth(this.getLockedWidth());
740 if(headersToo === true){
741 this.updateHeaders();
742 this.updateHeaderSortState();
744 this.processRows(0, true);
746 this.applyEmptyText();
747 this.fireEvent('refresh', this);
750 onDenyColumnLock : function(){
754 initData : function(ds, cm){
756 this.cm.un('columnlockchange', this.onColumnLock, this);
758 Ext.ux.grid.LockingGridView.superclass.initData.call(this, ds, cm);
760 this.cm.on('columnlockchange', this.onColumnLock, this);
764 onColumnLock : function(){
768 handleHdMenuClick : function(item){
769 var index = this.hdCtxIndex,
771 id = item.getItemId(),
772 llen = cm.getLockedCount();
775 if(cm.getColumnCount(true) <= llen + 1){
776 this.onDenyColumnLock();
779 cm.setLocked(index, true);
781 cm.moveColumn(index, llen);
782 this.grid.fireEvent('columnmove', index, llen);
786 if(llen - 1 != index){
787 cm.setLocked(index, false, true);
788 cm.moveColumn(index, llen - 1);
789 this.grid.fireEvent('columnmove', index, llen - 1);
791 cm.setLocked(index, false);
795 return Ext.ux.grid.LockingGridView.superclass.handleHdMenuClick.call(this, item);
800 handleHdDown : function(e, t){
801 Ext.ux.grid.LockingGridView.superclass.handleHdDown.call(this, e, t);
802 if(this.grid.enableColLock !== false){
803 if(Ext.fly(t).hasClass('x-grid3-hd-btn')){
804 var hd = this.findHeaderCell(t),
805 index = this.getCellIndex(hd),
806 ms = this.hmenu.items, cm = this.cm;
807 ms.get('lock').setDisabled(cm.isLocked(index));
808 ms.get('unlock').setDisabled(!cm.isLocked(index));
813 syncHeaderHeight: function(){
814 var hrow = Ext.fly(this.innerHd).child('tr', true),
815 lhrow = Ext.fly(this.lockedInnerHd).child('tr', true);
817 hrow.style.height = 'auto';
818 lhrow.style.height = 'auto';
819 var hd = hrow.offsetHeight,
820 lhd = lhrow.offsetHeight,
821 height = Math.max(lhd, hd) + 'px';
823 hrow.style.height = height;
824 lhrow.style.height = height;
828 updateLockedWidth: function(){
829 var lw = this.cm.getTotalLockedWidth(),
830 tw = this.cm.getTotalWidth() - lw,
831 csize = this.grid.getGridEl().getSize(true),
832 lp = Ext.isBorderBox ? 0 : this.lockedBorderWidth,
833 rp = Ext.isBorderBox ? 0 : this.rowBorderWidth,
834 vw = (csize.width - lw - lp - rp) + 'px',
835 so = this.getScrollOffset();
836 if(!this.grid.autoHeight){
837 var vh = (csize.height - this.mainHd.getHeight()) + 'px';
838 this.lockedScroller.dom.style.height = vh;
839 this.scroller.dom.style.height = vh;
841 this.lockedWrap.dom.style.width = (lw + rp) + 'px';
842 this.scroller.dom.style.width = vw;
843 this.mainWrap.dom.style.left = (lw + lp + rp) + 'px';
845 this.lockedInnerHd.firstChild.style.width = lw + 'px';
846 this.lockedInnerHd.firstChild.firstChild.style.width = lw + 'px';
847 this.innerHd.style.width = vw;
848 this.innerHd.firstChild.style.width = (tw + rp + so) + 'px';
849 this.innerHd.firstChild.firstChild.style.width = tw + 'px';
852 this.lockedBody.dom.style.width = (lw + rp) + 'px';
853 this.mainBody.dom.style.width = (tw + rp) + 'px';
858 Ext.ux.grid.LockingColumnModel = Ext.extend(Ext.grid.ColumnModel, {
860 * Returns true if the given column index is currently locked
861 * @param {Number} colIndex The column index
862 * @return {Boolean} True if the column is locked
864 isLocked : function(colIndex){
865 return this.config[colIndex].locked === true;
869 * Locks or unlocks a given column
870 * @param {Number} colIndex The column index
871 * @param {Boolean} value True to lock, false to unlock
872 * @param {Boolean} suppressEvent Pass false to cause the columnlockchange event not to fire
874 setLocked : function(colIndex, value, suppressEvent){
875 if (this.isLocked(colIndex) == value) {
878 this.config[colIndex].locked = value;
879 if (!suppressEvent) {
880 this.fireEvent('columnlockchange', this, colIndex, value);
885 * Returns the total width of all locked columns
886 * @return {Number} The width of all locked columns
888 getTotalLockedWidth : function(){
890 for (var i = 0, len = this.config.length; i < len; i++) {
891 if (this.isLocked(i) && !this.isHidden(i)) {
892 totalWidth += this.getColumnWidth(i);
900 * Returns the total number of locked columns
901 * @return {Number} The number of locked columns
903 getLockedCount : function() {
904 var len = this.config.length;
906 for (var i = 0; i < len; i++) {
907 if (!this.isLocked(i)) {
912 //if we get to this point all of the columns are locked so we return the total
917 * Moves a column from one position to another
918 * @param {Number} oldIndex The current column index
919 * @param {Number} newIndex The destination column index
921 moveColumn : function(oldIndex, newIndex){
922 var oldLocked = this.isLocked(oldIndex),
923 newLocked = this.isLocked(newIndex);
925 if (oldIndex < newIndex && oldLocked && !newLocked) {
926 this.setLocked(oldIndex, false, true);
927 } else if (oldIndex > newIndex && !oldLocked && newLocked) {
928 this.setLocked(oldIndex, true, true);
931 Ext.ux.grid.LockingColumnModel.superclass.moveColumn.apply(this, arguments);