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
});
}
}
}]
});
如何让树扩展?我试过了
root: {
expanded: true
}
但它仍然不起作用。
答案 0 :(得分:4)
将此添加到您的模型中:
{ name: 'expanded', type: 'boolean', defaultValue: true, persist: false },
或者,对于从服务器返回的每个节点,将expanded
设置为true。
答案 1 :(得分:0)
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}
] }
]
}
});