PDA

View Full Version : Adding TreeStore to TreePanel on instantiation



hermann.s
22 Aug 2013, 5:47 AM
Hi, I am trying to instantiate a custom TreePanel, but want to know if it possible to pass the store to the constructor. This doesn't seem to work as I get a Uncaught TypeError: Cannot read property 'added' of undefined:


var sidePanelStore = Ext.create('Ext.data.TreeStore', {
root: {
expanded: true,
text:"",
user:"",
status:"",
children:
[
{ text:"Projects", leaf: true },
{ text:"Business Partner", leaf: true },
{ text:"Current Tasks", leaf: true },
{ text:"Closed Tasks", leaf: true },
{ text:"Search", leaf: true },
{ text:"Options",
children:
[
{ text:"Delegation", leaf: true }
]
},
{ text:"Help", leaf: true }
]
}
});
var sidePanel = new Base.TreePanel('', 'Main Menu', sidePanelStore);

The class :



Ext.define('Base.TreePanel', {
extend: 'Ext.tree.Panel',


id: '',
title: '',
width: @BFE.Frontend.Main.MenuWidth,

animate: false,
autoscroll: true,
collapsible: true,
collapseDirection: 'left',
collapseMode: 'header',
frame: false,
lines: false,
region: 'west',
rootVisible: false,
useArrows: true,
renderTo: Ext.getBody(),
store: '',


constructor : function(config)
{
this.initConfig(config);
},


constructor : function(id, title, store)
{
this.id = id;
this.title = title,
this.store = store;
}
});

Any ideas?

hermann.s
22 Aug 2013, 6:38 AM
Geez,

the problem was that I forgot to add


this.callParent();

to the end of the constructor.

Now it works alright.