如何在页面加载时扩展树面板 - EXTJS 4
问题描述:
var tree = Ext.create('Ext.tree.Panel', {
store: store,
rootVisible: false,
//useArrows: true,
frame: true,
title: 'Vehicle List',
region:'west',
width: 200,
root: {
expanded: true
},
checked : false,
height: 250,
dockedItems: [{
xtype: 'toolbar',
items: {
text: 'Get checked nodes',
handler: function(){
var records = tree.getView().getChecked(),
names = [];
Ext.Array.each(records, function(rec){
names.push(rec.get('MainID'));
});
Ext.MessageBox.show({
title: 'Selected Nodes',
msg: names.join('<br />'),
icon: Ext.MessageBox.INFO
});
}
}
}]
});
如何让树扩展?我试过如何在页面加载时扩展树面板 - EXTJS 4
root: {
expanded: true
}
但它仍然不起作用。你从服务器返回的每个节点
{ name: 'expanded', type: 'boolean', defaultValue: true, persist: false },
或可选择地设置expanded
为true:
答
添加到您的模型。
答
root: {
expanded: true
}
这应该在您的商店的定义。
像下面这样。
var store = Ext.create('Ext.data.TreeStore', {
root: {
expanded: true,
children: [
{ text: "a", leaf: true },
{ text: "b", expanded: true, children: [
{ text: "c", leaf: true },
{ text: "d", leaf: true}
] }
]
}
});
+0
如果向下选举人添加评论,将不胜感激。这不像是拿走我的钱。这是一个社区。它会帮助其他人 – hop 2014-01-29 11:28:43
+0
我不知道为什么有人投这个票。比我认为的接受答案更好的答案 – 2014-11-24 13:55:16
替代解决方案适用于我。 – Michel 2016-07-19 20:51:40