1. #1
    Sencha User
    Join Date
    Jul 2012
    Posts
    3
    Vote Rating
    0
    Answers
    1
    fabergé is on a distinguished road

      0  

    Default Answered: ExtJs dynamically load store in menu

    Answered: ExtJs dynamically load store in menu


    Hi,

    I'm trying to do the following,
    I've got a store with 'favorite' records and i like them to display in a menu structure dynamically. I get the following error if i run it with the following code: Unable to get value of the property 'add': object is null or undefined. Is there any other way to do this?

    Store load:
    Code:
    var lFilterStore = Ext.create('WorkB.store.general.filter.Filters');
    lFilterStore.load({
          callback: function (records) {
             var lPersonsFavMenu = me.down('menuitem[name=favoritePersonMenu]');
             Ext.each(records, function (record) {
                      lPersonsFavMenu.item.add({ text: record.get('Name') });
             });
          }
    });

    Menu structure:
    Code:
    xtype: 'menu',
    showSeparator: false,
    floating: false,
    border: 0,
    margin: '0 0 5 0',
    items: [{
           text: 'Favorieten',
           menu: [{
                text: 'Person',
                name: 'favoritePersonMenu'
           }, {
                text: 'Customer',
                name: 'favoriteCustomerMenu'
          }]
    }]

  2. Change .items.add with .menu.add

    Code:
    var lFilterStore = Ext.create('WorkB.store.general.filter.Filters');
    lFilterStore.load({      
          callback: function (records) {         
                        var lPersonsFavMenu = me.down('menuitem[name=favoritePersonMenu]');  
                        Ext.each(records, function (record) {
                                lPersonsFavMenu.menu.add({ text: record.get('Name') });
                        });
          }
    });

  3. #2
    Sencha User
    Join Date
    Mar 2011
    Posts
    114
    Vote Rating
    6
    Answers
    3
    johanhaest is on a distinguished road

      0  

    Default


    Change .items.add with .menu.add

    Code:
    var lFilterStore = Ext.create('WorkB.store.general.filter.Filters');
    lFilterStore.load({      
          callback: function (records) {         
                        var lPersonsFavMenu = me.down('menuitem[name=favoritePersonMenu]');  
                        Ext.each(records, function (record) {
                                lPersonsFavMenu.menu.add({ text: record.get('Name') });
                        });
          }
    });

Thread Participants: 1

Tags for this Thread