This is a migrated thread and some comments may be shown as answers.

Remove subitem of RadMenuItem

1 Answer 102 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Henric
Top achievements
Rank 1
Henric asked on 06 Jan 2013, 05:10 PM
I have a some radmenu items with subitems in a dropdown and I need to remove the subitems, my code is.

function RemoveItems() {
            var menu = $find("<%= ResourceContextMenu.ClientID %>");
            var items = menu.findItemByText("Resources");
            for (var i = 0; i < items.get_count(); i++) {
                items.remove(i);
            }
            menu.trackChanges();
            menu.commitChanges();
        }
But i get an error in get_count.. I accomplish to remove the Resource Item but the only thing i want to remove is the Resource subitems..
What is wrong with my code?

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 07 Jan 2013, 04:23 AM
Hi Henric,

Try the following code snippet to achieve your scenario.

JS:
<script type="text/javascript">
    function RemoveItems() {
        var menu = $find("<%= ResourceContextMenu.ClientID %>");
        var items = menu.findItemByText("Resources");
        var x = items.get_items().get_count();
        while (x >= 0) {
            items.get_items().removeAt(0);
            x = x - 1;
        }
        menu.trackChanges();
        menu.commitChanges();
    }
</script>

Hope this helps.

Regards,
Princy.
Tags
Calendar
Asked by
Henric
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or