1. #1
    Sencha User
    Join Date
    Mar 2012
    Posts
    28
    Vote Rating
    0
    Answers
    2
    alexgrimaldi is on a distinguished road

      0  

    Default Answered: Populate a TitleBar using a store

    Answered: Populate a TitleBar using a store


    Hi, I need to create a TitleBar which is sucked into a set of screens. The TitleBar elements are drop-down lists. The items within the drop-down lists must be dynamic and must be loaded from a data file.

    I've managed to load the data but I cannot pass the data back to the TitleBar. In other words, I need somehow to create a reference to the titlebar. I've marked in red the code that fails.

    Code:
    Ext.define('CustomerToolbar', {
        extend: 'Ext.TitleBar',
    
    
        xtype: 'customer-toolbar',
    
    
        initialize: function() {
            this.callParent(arguments);
          
            this.loadItems();
    
    
    
    
            console.info("end of init");       
        },
    
    
        config: {
            layout: 'hbox',
    
    
            defaults: {
    
    
            }
        },
    
    
        loadItems: function (titleBar) {
            var itemList = [];
            var itemOptionList = [];
    
    
            Ext.getStore('OrganizationStore').load(function(organizationList) {
    
    
                console.info("getOptionList inside the store load function");
    
    
                Ext.each(organizationList, function(organization) {
    
    
                    console.info("organizations: " + organization.get("name") + "," + organization.get("id"));
                    itemOptionList.push({text: organization.get("name"), value: organization.get("id")});
    
    
                });
    
    
                console.info("itemList - about to populate");
                itemList.push(
                    {
                        xtype: 'selectfield',
                        name: 'customerOptions',
                        id :'organizationId',
                        options: itemOptionList,
                        action :'selectOrganizationAction'
                    }
                );
                console.info("itemList - populated");
                console.info("itemList within the store block: " + itemList);
    
    
                console.info("this: " + this);
    
    
      //THIS IS WHERE I AM HAVING THE PROBLEM. The variable this points to the store and not to the TitleBar
                //this.setItems(itemList);
    
    
            });
    
    
            console.info("itemList outside the store block: " + itemList);
        }
    
    
    
    
    });
    Many Thanks,
    Alex

  2. Why not just use the store on the selectfield? http://docs.sencha.com/touch/2-0/#!/...lect-cfg-store

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,617
    Vote Rating
    435
    Answers
    3102
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    Why not just use the store on the selectfield? http://docs.sencha.com/touch/2-0/#!/...lect-cfg-store
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Sencha User
    Join Date
    Mar 2012
    Posts
    28
    Vote Rating
    0
    Answers
    2
    alexgrimaldi is on a distinguished road

      0  

    Default


    It worked! Thanks again mate