PDA

View Full Version : custom menu items



wp.joju
22 Feb 2010, 5:54 AM
hi there, i'm trying to make a server side structure to be used as a client side menu item

server side


[Serializable]
public struct ContextMenuItem
{
public string text;
public string handler;
}



client side


var itemmenu_custom = new Ext.menu.Menu();
if (record.get('contextmenu') != null)
{
for(var ctr = 0; ctr < record.get('contextmenu').length; ctr++)
{
itemmenu_custom.add({text:record.get('contextmenu')[ctr].text, handler:new Function(record.get('contextmenu')[ctr].handler)});
}
itemmenu_custom.showAt(e.getXY());
}


the menu is showing up but the handler is not firing, what am i missing, and also how can i add multiple handlers per menu item?

wp.joju
22 Feb 2010, 6:01 AM
got the answer from this one

http://www.extjs.com/forum/showthread.php?t=61674

used this code instead


itemmenu_custom.add({text:record.get('contextmenu')[ctr].text, handler:eval("record.get('contextmenu')[ctr].handler = "+ record.get('contextmenu')[ctr].handler)});


but how can i add multiple event listener from the server side since this is only adding the click event handler?