PDA

View Full Version : How to get TreeStore or TreePanel when an itemAppend event occurs ?



GuillaumeF
24 Aug 2012, 7:27 AM
Hi,

Using ExtJS 4.1, how to get TreeStore or TreePanel when an itemAppend event occurs ?
I don't see any reference to the TreeStore or the Panel during the event nor the nodes attributes.

See below the code that doesn't work.

Note there is not only one ContainersTree. Multiple ones can be created, each one is displayed in a separate tab of a TabPanel.

Regards,

Guillaume

VIEW :
Ext.define('Link.view.module.ContainersTree', {
extend: 'Ext.tree.Panel',
alias: 'widget.ModuleContainersTree',

initComponent: function() {
this.store = Ext.create('Ext.data.TreeStore', {
model: 'Link.model.Container',
...
}
this.relayEvents(this.store, ['load', 'append'], 'store');
this.callParent(arguments);
},
...
});

CONTROLLER :
Ext.define('Link.controller.module.Edit', {
extend: 'Ext.app.Controller',

views: [ 'module.ContainersTree'],

models: ['Container'],

init: function() {
this.control({
'ModuleContainersTree': {
itemappend: function(parentNode, childNode) {
// HOW TO GET THE ModuleContainersTree PANEL HERE ?
},
storeappend: function(parentNode, childNode) {
// HOW TO GET THE TREESTORE HERE ?
}
}
});
...
});

GuillaumeF
24 Aug 2012, 7:48 AM
I got it. It works.

The node, which is also an Ext.data.Model, had a "store" attribute.

CONTROLLER :

...

this.control({
'ModuleContainersTree': {
storeappend: function(parentNode, childNode) {
var nodeStore = parentNode.store; // It is an Ext.data.NodeStore object
var treeStore = nodeStore.treeStore; // Here it is the tree store
...
}
}
});
...

Hope it can help.

scottmartin
24 Aug 2012, 9:17 AM
Thank you for providing the solution.

Scott.