最近用了很多开源的东西,发现开源的东西也是Bug如云,这不,又遇到了ExtJs2.2中的Grid的Bug。
bug1:出现纵向滚动条后,将横向滚动条拖到最后,然后会发现每选择一条记录整个grid就会往左移,右边空出一部份空白。
Bug2:出现横向滚动条后,向右稍拉滚动条,然后点击任意一行,会发现行内容向左偏移,滚动条向右越多,偏移越明显。
================
分析:经查Ex.t2.3已无此Bug,跟踪两个代码后总结如下(我可是跟踪了好久的)
Bug1:修改GridView.js文件
// private updateAllColumnWidths : function(){ var tw = this.getTotalWidth(); var clen = this.cm.getColumnCount(); var ws = []; for(var i = 0; i < clen; i++){ ws[i] = this.getColumnWidth(i); } this.innerHd.firstChild.style.width = this.getOffsetWidth(); this.innerHd.firstChild.firstChild.style.width = tw; this.mainBody.dom.style.width = tw; for(var i = 0; i < clen; i++){ var hd = this.getHeaderCell(i); hd.style.width = ws[i]; } var ns = this.getRows(), row, trow; for(var i = 0, len = ns.length; i < len; i++){ row = ns[i]; row.style.width = tw; if(row.firstChild){ row.firstChild.style.width = tw; trow = row.firstChild.rows[0]; for(var j = 0; j < clen; j++){ trow.childNodes[j].style.width = ws[j]; } } } this.onAllColumnWidthsUpdated(ws, tw); }, // private updateColumnWidth : function(col, width){ var w = this.getColumnWidth(col); var tw = this.getTotalWidth(); this.innerHd.firstChild.style.width = this.getOffsetWidth(); this.innerHd.firstChild.firstChild.style.width = tw; this.mainBody.dom.style.width = tw; var hd = this.getHeaderCell(col); hd.style.width = w; var ns = this.getRows(), row; for(var i = 0, len = ns.length; i < len; i++){ row = ns[i]; row.style.width = tw; if(row.firstChild){ row.firstChild.style.width = tw; row.firstChild.rows[0].childNodes[col].style.width = w; } } this.onColumnWidthUpdated(col, w, tw); }, // private updateColumnHidden : function(col, hidden){ var tw = this.getTotalWidth(); this.innerHd.firstChild.style.width = this.getOffsetWidth(); this.innerHd.firstChild.firstChild.style.width = tw; this.mainBody.dom.style.width = tw; var display = hidden ? 'none' : ''; var hd = this.getHeaderCell(col); hd.style.display = display; var ns = this.getRows(), row; for(var i = 0, len = ns.length; i < len; i++){ row = ns[i]; row.style.width = tw; if(row.firstChild){ row.firstChild.style.width = tw; row.firstChild.rows[0].childNodes[col].style.display = display; } } this.onColumnHiddenUpdated(col, hidden, tw); delete this.lastViewWidth; // force recalc this.layout(); },
/** * Focuses the specified cell. * @param {Number} row The row index * @param {Number} col The column index */ focusCell : function(row, col, hscroll){
这个函数写的写法有问题。竟然把Grid下方的坐标位置取错了,具体做法我是从Ext2.3上摘过来的。
可是这里不让贴附件。大家自己去这里下载http://download.csdn.net/detail/xzknet/4408844吧。