Hybrid View

  1. #1
    Sencha User
    Join Date
    Aug 2011
    Posts
    3
    Vote Rating
    2
    alamottemitchell is on a distinguished road

      0  

    Default Unanswered: Tree Panel ignores root when store is a string

    Unanswered: Tree Panel ignores root when store is a string


    I have an Ext.tree.Panel, which I want to configure like so:
    Code:
    Ext.define('myTest.CoolTree', {
        extend:'Ext.tree.Panel',
        alias:'widget.coolTree',
        store:'coolTreeStore',
        rootVisible:true,
        root: {
            text: 'All',
            expanded: true
        }
    });
    If I do this, it completely ignores my root config, and uses the default (text=Root, expanded=false). It appears this is because the initComponent function for Ext.tree.Panel has a 3-part conditional whose first if is overly broad:

    Code:
    Ext.define('Ext.tree.Panel', {
    ...
        initComponent: function() {
    ...
             if (Ext.isString(me.store)) {
                 me.store = Ext.StoreMgr.lookup(me.store);
             } else if (!me.store || Ext.isObject(me.store) && !me.store.isStore) {
                  me.store = new Ext.data.TreeStore(Ext.apply({}, me.store || {}, {
                      root: me.root,
                      fields: me.fields,
                      model: me.model,
                      folderSort: me.folderSort
                  }));
            } else if (me.root) {
                  me.store = Ext.data.StoreManager.lookup(me.store);
                  me.store.setRootNode(me.root);
                 if (me.folderSort !== undefined) {
                       me.store.folderSort = me.folderSort;
                       me.store.sort();
                  }
            }
    ...
    My string is a store, so the first case hits, and that case ignores root. Is that intentional? For my use, I want to hit the last else-if, where it treats my store as a string (it is) and respects my root config.

    My workaround is to override initcomponent, call parent, and then:

    Code:
            me.setRootNode({text:'All', expanded:true});
    I'd definitely prefer to not do that. Thoughts?

  2. #2
    Sencha User
    Join Date
    May 2011
    Location
    Ukraine, Rivne
    Posts
    250
    Answers
    44
    Vote Rating
    42
    redraid has a spectacular aura about redraid has a spectacular aura about redraid has a spectacular aura about

      0  

    Default


    Move
    Code:
        root: {
            text: 'All',
            expanded: true
        }
    from tree to TreeStore

Thread Participants: 1

Tags for this Thread