3
如何創建Ext.tree.Panel,當節點展開/摺疊時自動調整大小以適合其內容?Ext.tree.Panel自動高度在ExtJS 4
如何創建Ext.tree.Panel,當節點展開/摺疊時自動調整大小以適合其內容?Ext.tree.Panel自動高度在ExtJS 4
這是一個骯髒的解決方法,但作爲一個快速解決方案對我來說工作得很好。
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);
}
嘿它可能是醜陋的,但它的工作完美!非常感謝。 – phatmann
您可以將超時從200減少到1,沒有任何問題 –