Thanks for the great work. Now working with my ultrawide reports is much more fun
Just one though, when I add the tooltip property to the column definition they don't show up. Usually the tooltip would pop up when hovering the column's header.
The locked column "Company" is bigger than the content, and so everything else gets pushed to the right. I think some other people have mentioned this, but not that it only affects Firefox.
The good news is that when the page is resized, the grid re-calcs itself and then all seems well. So maybe the code just needs an extra refresh after the initial calculations? I'm sure I can work around it by adding that in myself, but I thought it was worth mentioning.
//Template has changed and we need a few other pointers to keep track
initElements : function() {
var E = Ext.Element;
var el = this.grid.getGridEl();
el = el.dom.firstChild;//.dom.childNodes[1];
var cs = el.childNodes;
this.el = new E(el);
this.lockedWrap = new E(cs[0]);
this.lockedHd = new E(this.lockedWrap.dom.firstChild);
this.lockedInnerHd = this.lockedHd.dom.firstChild;
this.lockedScroller = new E(this.lockedWrap.dom.childNodes[1]);
this.lockedBody = new E(this.lockedScroller.dom.firstChild);
this.mainWrap = new E(cs[1]);
this.mainHd = new E(this.mainWrap.dom.firstChild);
this.innerHd = this.mainHd.dom.firstChild;
this.scroller = new E(this.mainWrap.dom.childNodes[1]);
if (this.forceFit) {
this.scroller.setStyle('overflow-x', 'hidden');
}
this.mainBody = new E(this.scroller.dom.firstChild);
this.focusEl = new E(this.scroller.dom.childNodes[1]);
this.focusEl.swallowEvent("click", true);
this.resizeMarker = new E(cs[2]);
this.resizeProxy = new E(cs[3]);
},
// private
hasLockedRows : function() {
var fc = this.lockedBody.dom.firstChild;
return fc && fc.className != 'x-grid-empty';
},
processRows : function(startRow, skipStripe) {
if (this.ds.getCount() < 1) {
return;
}
skipStripe = skipStripe || !this.grid.stripeRows;
startRow = startRow || 0;
var cls = ' x-grid3-row-alt ';
var rows = this.getRows();
var lrows = this.getLockedRows();
for (var i = startRow, len = rows.length; i < len; i++) {
var row = rows[i];
var lrow = lrows[i];
row.rowIndex = i;
lrow.rowIndex = i;
if (!skipStripe) {
var isAlt = ((i+1) % 2 == 0);
var hasAlt = (' '+row.className + ' ').indexOf(cls) != -1;
if (isAlt == hasAlt) {
continue;
}
if (isAlt) {
row.className += " x-grid3-row-alt";
lrow.className += " x-grid3-row-alt";
} else {
row.className = row.className.replace("x-grid3-row-alt", "");
lrow.className = lrow.className.replace("x-grid3-row-alt", "");
}
}
}
},
updateSortIcon : function(col, dir) {
var sc = this.sortClasses;
var clen = this.cm.getColumnCount();
var lclen = this.cm.getLockedCount();
var hds = this.mainHd.select('td').removeClass(sc);
var lhds = this.lockedHd.select('td').removeClass(sc);
if (lclen > 0 && col < lclen) {
lhds.item(col).addClass(sc[dir == "DESC" ? 1 : 0]);
} else {
hds.item(col-lclen).addClass(sc[dir == "DESC" ? 1 : 0]);
}
},
updateAllColumnWidths : function() {
var tw = this.cm.getTotalWidth();
var lw = this.cm.getTotalLockedWidth();
var clen = this.cm.getColumnCount();
var lclen = this.cm.getLockedCount();
var ws = [];
for (var i = 0; i < clen; i++) {
ws[i] = this.getColumnWidth(i);
}
for (var i = 0; i < clen; i++) {
var hd = this.getHeaderCell(i);
hd.style.width = ws[i];
}
var ns = this.getRows();
var lns = this.getLockedRows();
for (var i = 0, len = ns.length; i < len; i++) {
ns[i].style.width = tw - lw;
ns[i].firstChild.style.width = tw-lw;
lns[i].style.width = lw;
lns[i].firstChild.style.width = lw;
for (var j = 0; j < lclen; j++) {
var row = lns[i].firstChild.rows[0];
row.childNodes[j].style.width = ws[j];
}
for (var j = lclen; j < clen; j++) {
var row = ns[i].firstChild.rows[0];
row.childNodes[j].style.width = ws[j];
}
}
this.onAllColumnWidthsUpdated(ws, tw);
},
updateColumnWidth : function(col, width) {
var w = this.cm.getColumnWidth(col);
var tw = this.cm.getTotalWidth();
var lclen = this.cm.getLockedCount();
var lw = this.cm.getTotalLockedWidth();
var hd = this.getHeaderCell(col);
hd.style.width = w;
if (g.enableColumnMove) {
this.columnDrag = new Ext.grid.GridView.ColumnDragZone(g, this.innerHd);
this.columnDrop = new Ext.grid.HeaderDropZone(g, this.mainHd.dom);
}
if (g.enableDragDrop || g.enableDrag) {
var dd = new Ext.grid.GridDragZone(g, {
ddGroup : g.ddGroup || 'GridDD'
});
}
this.updateHeaderSortState();
},
layout : function() {
if (!this.mainBody) {
return;
}
var g = this.grid;
var c = g.getGridEl(), cm = this.cm,
expandCol = g.autoExpandColumn,
gv = this;
var lw = cm.getTotalLockedWidth();
var csize = c.getSize(true);
var vw = csize.width;
renderHeaders : function() {
var cm = this.cm, ts = this.templates;
var ct = ts.hcell;
var tw = this.cm.getTotalWidth();
var lw = this.cm.getTotalLockedWidth();
var cb = [], lb = [], sb = [], lsb = [], p = {};
for (var i = 0, len = cm.getColumnCount(); i < len; i++) {
p.id = cm.getColumnId(i);
p.value = cm.getColumnHeader(i) || "";
p.style = this.getColumnStyle(i, true);
p.tooltip = this.getColumnTooltip(i);
addRowClass : function(row, cls) {
var r = this.getRow(row);
if (r) {
this.fly(r).addClass(cls);
r = this.getLockedRow(row);
this.fly(r).addClass(cls);
}
},
removeRowClass : function(row, cls) {
var r = this.getRow(row);
if (r) {
this.fly(r).removeClass(cls);
r = this.getLockedRow(row);
this.fly(r).removeClass(cls);
}
},
handleHdMenuClick : function(item) {
var index = this.hdCtxIndex;
var cm = this.cm, ds = this.ds;
switch (item.id) {
case "asc":
ds.sort(cm.getDataIndex(index), "ASC");
break;
case "desc":
ds.sort(cm.getDataIndex(index), "DESC");
break;
case "lock":
var lc = cm.getLockedCount();
if (cm.getColumnCount(true) <= lc+1) {
this.onDenyColumnLock();
return;
}
if (lc != index) {
cm.setLocked(index, true, true);
cm.moveColumn(index, lc);
this.grid.fireEvent("columnmove", index, lc);
} else {
cm.setLocked(index, true);
}
this.changeHeight();
break;
case "unlock":
var lc = cm.getLockedCount();
if ((lc-1) != index) {
cm.setLocked(index, false, true);
cm.moveColumn(index, lc-1);
this.grid.fireEvent("columnmove", index, lc-1);
} else {
cm.setLocked(index, false);
}
this.changeHeight();
break;
default:
index = cm.getIndexById(item.id.substr(4));
if (index != -1) {
if (item.checked && cm.getColumnsBy(this.isHideableColumn, this).length <= 1) {
this.onDenyColumnHide();
return false;
}
cm.setHidden(index, item.checked);
}
}
return true;
},
handleHdDown : function(e, t) {
if (Ext.fly(t).hasClass('x-grid3-hd-btn')) {
e.stopEvent();
var hd = this.findHeaderCell(t);
Ext.fly(hd).addClass('x-grid3-hd-menu-open');
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));
if (this.grid.enableColLock !== false) {
ms.get("lock").setDisabled(cm.isLocked(index));
ms.get("unlock").setDisabled(!cm.isLocked(index));
}
this.hmenu.on("hide", function() {
Ext.fly(hd).removeClass('x-grid3-hd-menu-open');
}, this, {single:true});
this.hmenu.show(t, "tl-bl?");
}
}
});
column resize problem with locking grid in firefox
column resize problem with locking grid in firefox
Thanks for the update huixjan. However, there are still some significant problems with the locking grid in firefox in particular. Here's my sample link, I updated it to use your new version of columnLock.js: http://64.209.140.177/javascript/rep...king_grid.html
The initial sizing problem is easy enough to work around, but also the columns don't allow you to resize widths in firefox. Seems to work fine in IE again.
this extension is great and very useful, but I have one question about it. How can I make it
work with GroupHeader plugin. When I use GridPanel with GroupHeader plugin it all works well, but when I use LockingGridPanel headers dissapears...