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

Collapse Child PanelBars when parent is closed

1 Answer 26 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Roger
Top achievements
Rank 1
Roger asked on 15 Jun 2011, 05:14 PM
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?

1 Answer, 1 is accepted

Sort by
0
Roger
Top achievements
Rank 1
answered on 16 Jun 2011, 12:21 PM
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
Tags
PanelBar
Asked by
Roger
Top achievements
Rank 1
Answers by
Roger
Top achievements
Rank 1
Share this question
or