PDA

View Full Version : TreeGrid columns fit



kotovsky
7 Mar 2010, 1:46 AM
How can I make the columns fit in tree grid? such as in GridPanel viewConfig: {forceFit: true} ?

Eugen_
8 Mar 2010, 8:36 AM
How can I make the columns fit in tree grid? such as in GridPanel viewConfig: {forceFit: true} ?

Change the TreeGrid and Ext.tree.ColumnResizer source code



Ext.ux.tree.TreeGrid = Ext.extend(Ext.tree.TreePanel, {

...

fitColumns: function() {
var nNewTotalWidth = this.getInnerWidth() - Ext.num(this.scrollOffset, Ext.getScrollBarWidth());
var nOldTotalWidth = this.getTotalColumnWidth();
var cs = this.getVisibleColumns();
var n, nUsed = 0;

for (n = 0; n < cs.length; n++) {
if (n == cs.length - 1) {
cs[n].width = nNewTotalWidth - nUsed - 1;
break;
}
cs[n].width = Math.floor((nNewTotalWidth / 100) * (cs[n].width * 100 / nOldTotalWidth)) - 1;
nUsed += cs[n].width;
}

this.updateColumnWidths();
},

...

onResize : function(w, h) {

...

this.fitColumns();
},

...

});


Ext.tree.ColumnResizer = Ext.extend(Ext.util.Observable, {

...

onEnd : function(e){

...

//tree.updateColumnWidths();
tree.fitColumns();

}
});