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

How-to Client-side Collapse and Expanded Item

2 Answers 41 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Phil
Top achievements
Rank 2
Phil asked on 07 Aug 2012, 09:56 PM
Hi:

I am trying to collapse an already expanded item.  It doesn't seem to work?
<script type="text/javascript">
    function OnClicking(sender, eventArgs) {
        var item = eventArgs.get_item();
        if (item.get_expanded()) {
            item.set_expanded(false);
            item.set_selected(false);
        }
    }
</script>

Phil

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 08 Aug 2012, 07:38 AM
Hi Phil,

Try the following code snippet to achieve your scenario.

JS:
<script type="text/javascript">
    function OnClicking(sender, eventArgs) {
        var item = eventArgs.get_item();
        if (item.get_expanded()) {
            eventArgs.set_cancel(true);
            item.set_expanded(false);
            item.set_selected(false);
        }
    }
</script>

Hope this helps.

Regards,
Princy.
0
Phil
Top achievements
Rank 2
answered on 08 Aug 2012, 11:40 AM
Hi Princy:

Works!  I was wondering if something like that was happening.

Thanks,
Phil
Tags
PanelBar
Asked by
Phil
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Phil
Top achievements
Rank 2
Share this question
or