Question

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
            }
Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top