ExtJs 4 Tree rootVisible false problem

I was building Ext.tree.Panel like this:


Ext.create('Ext.tree.Panel', {
    rootVisible : false,
    root   : {
        text    : 'Menu',
        children : [{
            text : 'Item 1',
            children : [{
                 text : 'Item 1.1',
                 leaf  : true
            },{
                 text : 'Item 1.2',
                 leaf  : true
            }]
        }, {
            text : 'Item 2',
            children : [{
                 text : 'Item 2.1',
                 leaf  : true
            }]
        }]
    }
});

And while instantiating I got this error: “Cannot read property ‘elements’ of undefined”. I searched this error w/o any luck. Then after looking demos and thinking a little bit I got the solution: root item must have expanded : true. So code must look like this:


Ext.create('Ext.tree.Panel', {
    rootVisible : false,
    root   : {
        text    : 'Menu',
        expanded : true,
        children : [{
            text : 'Item 1',
            children : [{
                 text : 'Item 1.1',
                 leaf  : true
            },{
                 text : 'Item 1.2',
                 leaf  : true
            }]
        }, {
            text : 'Item 2',
            children : [{
                 text : 'Item 2.1',
                 leaf  : true
            }]
        }]
    }
});

I hope this post will save your minimum 15 minutes 🙂

Advertisement

About Mariami Kupatadze
Oracle Certified Master Linkedin: https://www.linkedin.com/in/mariami-kupatadze-01074722/

3 Responses to ExtJs 4 Tree rootVisible false problem

  1. rsqw says:

    don’t work for me.

    Ext.define(‘DD.store.Languages’, {
    extend : “Ext.data.TreeStore”,
    rootVisible : false,
    root : {
    text : ‘Menu’,
    expanded : true,
    children : [{
    text : ‘Item 1’,
    children : [{
    text : ‘Item 1.1’,
    leaf : true
    },{
    text : ‘Item 1.2’,
    leaf : true
    }]
    }, {
    text : ‘Item 2’,
    children : [{
    text : ‘Item 2.1’,
    leaf : true
    }]
    }]
    },
    proxy : {
    type : ‘ajax’,
    url : DD.links.language.list.url
    }
    });

    Root node still visible

  2. rsqw says:

    sorry, it work’s, rootVisible must be specified in Ext.panel.Tree

  3. Thnx, I don’t know how much time it saved me, because it was the first page in Googles result 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: