Collapse Nodes on Click

8 posts, 1 answers
  1. Jeff Sager
    Jeff Sager avatar
    26 posts
    Member since:
    Aug 2006

    Posted 10 Mar 2015 Link to this post

    Is it possible to collapse a node when one of the nodes below are clicked?  I have a navigation control with multiple nodes with some nodes having "sub" nodes.  When one of the sub nodes are clicked the page does what I want (navigate a separate panel to a new page) but the node stays expanded unless another parent node is clicked on the navigation control itself is clicked.
    Thanks,
    Jeff
  2. Jeff Sager
    Jeff Sager avatar
    26 posts
    Member since:
    Aug 2006

    Posted 12 Mar 2015 in reply to Jeff Sager Link to this post

    Some more information.  I had a RadSplitter with two RadPanes, when I had the RadNavigation in Pane1 and clicked on an item, I would open a separate page in Pane2, clicking in Pane2 did not collapse the RadNavigation, I had to click anywhere in Pane1 to collapse the RadNavigation.  I stopped using the splitter and it seems OK now.  It would be nice to have the option to have the Nodes auto-collapse after being clicked.
    Thanks,
    Jeff
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Answer
    Ivan Danchev
    Admin
    Ivan Danchev avatar
    829 posts

    Posted 12 Mar 2015 Link to this post

    Hello,

    To make the RadNavigation nodes collapse on click you can subscribe to the control's OnClientNodeClicked event and call the _collapseAll method in its event handler as shown below:
    function OnClientNodeClicked(sender, eventArgs) {              
        if (eventArgs.get_node().get_level() > 0) {
             sender._collapseAll();
        }
    }

    <telerik:RadNavigation ID="RadNavigation1" runat="server" OnClientNodeClicked="OnClientNodeClicked">

    Regards,
    Ivan Danchev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  5. Jeff Sager
    Jeff Sager avatar
    26 posts
    Member since:
    Aug 2006

    Posted 20 Mar 2015 in reply to Ivan Danchev Link to this post

    Thanks Ivan, worked perfectly!
  6. Jon
    Jon avatar
    813 posts
    Member since:
    Oct 2008

    Posted 01 Feb Link to this post

    Hi Ivan,

    This technique doesn't appear to work on  the hamburger menu when there is a second level.  It closes the second level but NOT the main hamburger menu.  How do you force that to hide?

    Regards

    Jon

  7. Jon
    Jon avatar
    813 posts
    Member since:
    Oct 2008

    Posted 01 Feb in reply to Jon Link to this post

    Ah, I've realised that the hamburger isn't a normal node and that would explain it not collapsing.  I've now found the _collapseSandwich function and used that, works very well now.  

    Is this going to be added as a proper function so that it doesn't get dropped after any internal rewrites?  I always get worried about using the underscore functions.

    Regards

    Jon

  8. Plamen
    Admin
    Plamen avatar
    2729 posts

    Posted 04 Feb Link to this post

    Hi Jon,

    Thank you for your concern with RadControls - we will do our best to add public methods for expand and collapse of the MenuButton or the "sandwich" as soon as possible.

    Regards,
    Plamen
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  9. Jon
    Jon avatar
    813 posts
    Member since:
    Oct 2008

    Posted 08 Feb in reply to Plamen Link to this post

    Many thanks Plamen

    Regards

    Jon

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