PDA

View Full Version : problem with horizontal scroll bar



prince0901
16 Jan 2011, 10:07 PM
Hey all..... i found in one of the forums that to enable horizontal scrollbar in the grid this function has to be called after GridRender.

npfn.enableHorScroll = function(){
Ext.override(Ext.CompositeElement, {
getTextWidth: function() {
var i, e, els = this.elements, result = 0;
for(i = 0; e = Ext.get(els[i]); i++) {
result = Math.max(result, e.getTextWidth.apply(e, arguments));
}
return result;
}
});
Ext.override(Ext.grid.GridPanel, {
autoSizeColumns: function() {
this.colModel.suspendEvents();
for (var i = 0; i < this.colModel.getColumnCount(); i++) {
this.autoSizeColumn(i);
}
this.colModel.resumeEvents();
this.view.refresh(true);
},

autoSizeColumn: function(c) {
var col = this.view.el.select("td.x-grid3-td-" + this.colModel.getColumnId(c) + " div:first-child");
if (col) {
var w = col.getTextWidth() + Ext.get(col.elements[0]).getFrameWidth('lr') + 2;
this.colModel.setColumnWidth(c, w);
return w;
}
}
});
}
its working fine . but if there is a single record in the grid its giving trouble. I can't able to edit the record. can anyone help in this issue.... thanks.....
24316

Condor
17 Jan 2011, 12:51 AM
What does this have to do with a horizontal scrollbar?

Your problem is the vertical scrollbar. You can only edit a cell if the grid doesn't scroll while editing, but your grid isn't high enough, so it will always scroll.

prince0901
17 Jan 2011, 2:10 AM
Yeah sorry condor....i posted wrong.... actually my problem is with vertical scroll ... i want to avoid vertical scroll. i need horizontal scroll alone....

Condor
17 Jan 2011, 2:14 AM
That code you posted is to autosize columns to fit the content.

You need to give the grid a proper height (calculate as grid height + scroll offset).