1. #1
    Sencha User
    Join Date
    May 2010
    Posts
    10
    Vote Rating
    1
    Answers
    1
    GuillaumeF is on a distinguished road

      0  

    Default Answered: How to get TreeStore or TreePanel when an itemAppend event occurs ?

    Answered: How to get TreeStore or TreePanel when an itemAppend event occurs ?


    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 :
    Code:
    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 :
    Code:
    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 ?
                        }
                    }
            });
        ...
    });

  2. I got it. It works.

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

    CONTROLLER :
    Code:
    ...
    
    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.

  3. #2
    Sencha User
    Join Date
    May 2010
    Posts
    10
    Vote Rating
    1
    Answers
    1
    GuillaumeF is on a distinguished road

      0  

    Default


    I got it. It works.

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

    CONTROLLER :
    Code:
    ...
    
    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.

  4. #3
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,154
    Vote Rating
    475
    Answers
    685
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    Thank you for providing the solution.

    Scott.

Thread Participants: 1