ExtJs 4 Tree rootVisible false problem
May 21, 2011 3 Comments
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 🙂
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
sorry, it work’s, rootVisible must be specified in Ext.panel.Tree
Thnx, I don’t know how much time it saved me, because it was the first page in Googles result 🙂