Does anyone know how to refresh the get_count() value after removing a menu item on client side?
I use the following to remove the menu header item after the last child item is removed but the get_count() function keeps returning the maximum amount of child items that were created by get_items().add(...).
Here is the code I use:
It works to add and remove items under the item "Tabs" but when a child item is removed from the menu "Tabs" the get_count() returns the same value for point "a" and point "b" in the alert functions of RemoveMenuItem. Just to make myself clear, the item does get removed as expected.
I use the following to remove the menu header item after the last child item is removed but the get_count() function keeps returning the maximum amount of child items that were created by get_items().add(...).
Here is the code I use:
function
AddNewMenuItem(itemText,itemValue) {
var
menu = $find(MainMenu_ID);
var
menuTabsItem = menu.findItemByText(
"Tabs"
);
var
menuItem =
new
Telerik.Web.UI.RadMenuItem();
if
(!menuTabsItem) {
menuItem.set_text(
"Tabs"
);
menuItem.set_value(
""
);
menu.get_items().add(menuItem);
menuTabsItem = menu.findItemByText(
"Tabs"
);
}
menuItem =
new
Telerik.Web.UI.RadMenuItem();
menuItem.set_text(itemText);
menuItem.set_value(itemValue);
menuTabsItem.get_items().add(menuItem);
}
function
RemoveMenuItem(itemValue) {
var
menu = $find(MainMenu_ID);
var
menuTabsItem = menu.findItemByText(
"Tabs"
);
var
menuTabsItemToRemove = menu.findItemByValue(itemValue);
if
(menuTabsItem) {
alert(
"a "
+ menuTabsItem.get_items().get_count())
menu.get_items().remove(menuTabsItemToRemove);
alert(
"b "
+ menuTabsItem.get_items().get_count())
if
(menuTabsItem.get_items().get_count() == 0) {
menu.get_items().remove(menuTabsItem);
}
}
}
It works to add and remove items under the item "Tabs" but when a child item is removed from the menu "Tabs" the get_count() returns the same value for point "a" and point "b" in the alert functions of RemoveMenuItem. Just to make myself clear, the item does get removed as expected.