View Full Version : Dynamically Make Ext.Toolbar.MenuButton

5 Mar 2008, 6:32 PM
How do I dynamically create a Ext.Toolbar.SplitButton?

I have text values that are being pulled via AJAX and want to create dropdown items.

5 Mar 2008, 7:08 PM
Assuming your server returns something like:

text: 'Menu Item 1'
text: 'Menu Item 2'

You could do

//inside response
var items = Ext.decode(response.responseText); //items can now be used to pass to the split button.

6 Mar 2008, 1:49 PM
Not sure why it's not working, here's what I'm doing:

Here's the returned JSON:


Here's the code:

var MyObj = {};

MyObj = Ext.decode([{"text":"item1","group":"group1","checked":false},{"text":"item2","group":"group1","checked":false}]);

MySplitButton = new Ext.Toolbar.SplitButton({
id: "mysplitbuttonmenu",
text: "Select One...",
menu: {
items: MyObj

This isn't working, it gives me an error:

missing ] after element list [Break on this error] ([object Object])