PDA

View Full Version : removing sub menu items help



MoShAn480
16 Apr 2007, 8:38 AM
Hi,

I have a dynamic menu which has sub menus as well. The sub menu items are added and deleted using the following code:


Add:

cannedMessages.items.get(menuId).menu.addMenuItem (new Ext.menu.Item({
text: title,
id: messageId,
cls: 'x-btn-text-icon',
handler: selectCannedMessage}));

Remove:

var item = cannedMessages.items.get('userCannedMessages').menu.items.get(id);
cannedMessages.items.get('userCannedMessages').menu.remove(item);

When the number of items removed is zero, the arrow is still displayed making it confusing to the user as if there are sub items there. Also, when all the items are removed and empty list in IE displays a blank submenu. I have added the following code when removing ite,s and items.length == 0:

if (cannedMessages.items.get('userCannedMessages').menu.items.length == 0)
{
//alert("is zero");
cannedMessages.items.get('userCannedMessages').menu = null;
}

This seems to fix it in, but the arrow is still there. This issue is also true for the reverse. When i start with an empty menu, and add a new submenu item, then the arrow designating more items are available does not render.

Am i adding and removing the submenu items incorrectly, or is this a bug?

Any help would be great!

Thanks!