Collapse Child PanelBars when parent is closed

2 posts, 0 answers
  1. Roger
    Roger avatar
    12 posts
    Member since:
    Aug 2012

    Posted 15 Jun 2011 Link to this post

    I have a Multi-levelled PanelBar.  If the user opens up into, say level3 and then closes the root, I want to collapse all child panels, so that when they open from the root again all children are collapsed.

    Can this be done?
  2. Roger
    Roger avatar
    12 posts
    Member since:
    Aug 2012

    Posted 16 Jun 2011 Link to this post

    I have implemented this which seems to work - I post it incase it will help others.  I need this because I have several levels of information and it just gets very cluttered and the user gets a little bit "lost" during navigation!

    <script type="text/javascript">
        function OnClientItemCollapse(sender, eventArgs) {
            var item = eventArgs.get_item();
            if (item.get_level() != 0) {
                return;
            }
            var childItems = item.get_items();
            var childItemsArray = childItems.toArray();
            if (childItemsArray) {
                for (var i = 0; i < childItemsArray.length; i++) {
                    childItemsArray[i].collapse();
                }
            }
        }
    </script>

    I am building the PanelBar programmatically so add the OnClientItemCollapse definition in the code behind.

    Roger
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top