Treepanel with rootVisible = true not shown

☆樱花仙子☆ 提交于 2019-12-13 16:03:58

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!