Remove subitem of RadMenuItem

2 posts, 0 answers
  1. Henric
    Henric avatar
    1 posts
    Member since:
    Jan 2013

    Posted 06 Jan 2013 Link to this post

    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?
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 06 Jan 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top