View Full Version : ExtJs dynamically load store in menu

30 Jul 2012, 12:24 AM

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:

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

Menu structure:

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'

30 Jul 2012, 12:33 AM
change this:

lPersonsFavMenu.item.add({ text: record.get('Name') });

to this:

lPersonsFavMenu.add({ text: record.get('Name') });