-
13 Feb 2008 3:56 AM #1
[HELP] Using .each() to create Ext.menu.Menu from DataStore
[HELP] Using .each() to create Ext.menu.Menu from DataStore
Hi guys, im getting a little confused attempting to make a Ext.menu.Menu with data from a DataStore.
How do i go about looping through the DataStore data to add it to the menu? I assume i should be using Ext.each() but im a little confused as how to go about it ?
-
13 Feb 2008 4:01 AM #2
Im guessing something like this is what im after
Code:Ext.each(ds.Status['WebRoles'].data.items, function(item, index, allItems){console.log(item)})
-
13 Feb 2008 4:03 AM #3
Store has an each method, you can just do:
Code:ds.each(function(record) { //etc }, scope);
-
13 Feb 2008 4:08 AM #4
That wont work will it? Do i need to create the menu first or just add to it?!Code:Ext.Panel({ title:'Test Menu Item', html: 'Testing the BBar Menu', bbar:[{ menu: Ext.each(ds.Status['WebRoles'].data.items, buildStatusMenu), text:'Website Role', }] }) function buildStatusMenu(item, index, allItems){ new Ext.menu.Item({text:item.data.printable_name}); }
-
13 Feb 2008 4:10 AM #5
The menu requires either a menu object, or a config object for a menu. I don't think you can just pass an array of menu items (short answer, no).
Code:var menu = new Ext.menu.Menu(); ds.each(function(record) { menu.add(doSomethingWithRecord); } ); bbar: menu...
-
13 Feb 2008 4:14 AM #6
Yeah, i thought it might have to been done that way - will have to fiddle with it a bit then
as i was having other problems with my app when creating the menu outside of the tabPanel creation.


Reply With Quote