-
29 Jul 2012 11:58 PM #1
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' }] }]
-
Best Answer Posted by johanhaest
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') }); }); } });
-
30 Jul 2012 12:49 AM #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') }); }); } });


Reply With Quote