Expand Parent and Child Items Client Side

4 posts, 0 answers
  1. Elke Kaminski
    Elke Kaminski avatar
    6 posts
    Member since:
    Mar 2009

    Posted 03 May 2012 Link to this post

    Hi there,

    I try to expand the parent and child items in client-side but it seems that you can't. This is my code:

    function OnClientItemClicking(sender, eventArgs) {
                var item = eventArgs.get_item();
                 
                if (item.get_expanded()) {
                    item.collapse();
                }
                else {
                    item.expand();
                }
     
                var panelBar = $find("ctl00_RadPanelBar1");
     
                var panelItem = panelBar.findItemByValue("AccountFooter");
                panelItem.show();
     
                panelItem = panelBar.findItemByValue("TopicFooter");
                panelItem.hide();
     
                var parentItem = item.get_items().getItem(0);
                parentItem.expand();
     
                eventArgs.set_cancel(true); // Cancel the postback
               
            }

    Thanks for quick help!
    Claudio

  2. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 08 May 2012 Link to this post

    Hello Elke,

    Looking at the code that you provided I can not find a reason why it is not working as expected. I would suggest that you take a look at the following demo as well where you can find a working example of how to expand/collapse RadPanelItems on the client-side. In case this does not help I would ask you to provide the markup that you use as well as explain the desired functionality that you are trying to achieve.

    Kind regards,
    Kate
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Elke Kaminski
    Elke Kaminski avatar
    6 posts
    Member since:
    Mar 2009

    Posted 10 May 2012 Link to this post

    Hi Kate,

    the demo doesn't help me.

    I have two Root Items in the PanelBar:

    Root 1
              --> ParentChild 1
                          --> Child 1
                          --> Child 2
    Root 2
              --> ParentChild 1
                          --> Child 1
                          --> Child 2

    Initial state is that all Items are collapsed. When clicking the first Root Item and after that clicking the second Root Item the second Root Item expands but the Child items don't. When I click the second root item then twice after that it expands the child items correctly.

    When clicking the second Root Item first (from initial state where everything is collapsed) it correctly expands its childitems.

    Thanks for quick help!
    Claudio
  5. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 11 Jun 2012 Link to this post

    Hi Claudio,

    Can you please provide the markup that you are using so I can test you scenario locally and inspect what is causing the behavior that you get? 

    Greetings,
    Kate
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top