How-to Client-side Collapse and Expanded Item

3 posts, 1 answers
  1. Phil
    Phil avatar
    273 posts
    Member since:
    Jul 2008

    Posted 07 Aug 2012 Link to this post

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

    Posted 08 Aug 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Phil
    Phil avatar
    273 posts
    Member since:
    Jul 2008

    Posted 08 Aug 2012 Link to this post

    Hi Princy:

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

    Thanks,
    Phil
Back to Top