How do I create Ext.tree.Panel that automatically resizes to fit its content when nodes are expanded/collapsed?
Asked
Active
Viewed 2,468 times
1 Answers
4
It's a bit of a dirty workaround, but as a quick solution works fine for me.
var tree = Ext.create('Ext.tree.Panel', {
//...
//configuration goes here
//...
animate: false,
//...
listeners:{
load: function(){
resetHeight(this);
},
itemexpand: function(){
resetHeight(this);
},
itemcollapse: function(){
resetHeight(this);
}
}
}
function resetHeight(cmp){
setTimeout(function(){
var innerElement = cmp.getEl().down('table.x-grid-table');
if(innerElement){
var height = innerElement.getHeight();
cmp.setHeight(height);
}
}, 200);
}

iamtankist
- 3,464
- 1
- 19
- 25
-
You can reduce the timeout from 200 to 1 with no problem – Rick Mohr Mar 01 '13 at 14:45