问题
My tree is shown correctly when using rootVisible: false
. However setting it to true
leads to no tree display and no error.
My aim is to show a root node that I can define as /
or Root
. How to achieve this?
My solution:
Putting rootVisible
to true
and adding this to my tree store:
root: {
id : '/',
expanded : false,
name : '/',
type : 'folder',
path : '/',
root : true
}
回答1:
The name for the Rootnode is Root
by default. But you can specify any other name.
var store = Ext.create('Ext.data.TreeStore', {
root: {
text: "/",
expanded: true,
children: [
{ text: "detention", leaf: true },
{ text: "homework", expanded: true, children: [
{ text: "book report", leaf: true },
{ text: "alegrbra", leaf: true}
] },
{ text: "buy lottery tickets", leaf: true }
]
}
});
Ext.create('Ext.tree.Panel', {
title: 'Simple Tree',
width: 200,
height: 150,
store: store,
rootVisible: true,
renderTo: Ext.getBody()
});
If this don't help please post more code from your data send by the server, TreeStore, reader.
来源:https://stackoverflow.com/questions/12404227/treepanel-with-rootvisible-true-not-shown