Treeview expand down to selected node on load and click

5 posts, 1 answers
  1. Mark
    Mark avatar
    90 posts
    Member since:
    Jul 2014

    Posted 04 Aug 2015 Link to this post

    Hi there,

     I need a hand on how to achieve this.  I have a page with a dynamically loaded treeview working fine on the left, and content on the right based on the tree view node that has been clicked.  When the content on the right is saved, it needs to reload both that content and the treeview - because the treeview might change based on the right content save.  I'm doing a full page reload, passing through the selected treeview node ID in the URL.

    On reloading, I need the selected ID node to be selected still (this is working fine), but also I need :-

    - the treeview to be expanded down to that node so that the selected node is visible to the user
    - to trigger the click even of that node such that the content on the right is reloaded from that event as currently

    How can I achieve this?  I can't find any loaded/rendered event to work with (I tried the page document.ready event but the treeview isn't available to the DOM at that point so threw an error, and also the dataBound event of the treeview but that didn't seem to trigger either, it just did nothing).

    Any help would be appreciated.

    Thanks, Mark

  2. Ivan Danchev
    Admin
    Ivan Danchev avatar
    829 posts

    Posted 07 Aug 2015 Link to this post

    Hello,

    You can expand the selected node by calling its expand() client-side method. This can be done in the RadTreeView's OnClientLoaded event handler:
    function OnClientLoad(sender, args) {
        var selectedNode = sender.get_selectedNode()
        selectedNode.expand();
    }

    This assumes the selection is not cleared across postbacks, otherwise you can use other methods of persisting the selected node's text, for instance in a hidden field's value, and use it to get a reference to the node and select/expand it.

    I am afraid the client side API does not have a method to invoke a node click event. You can consider executing your code that loads the node related content after calling expand().

    Regards,
    Ivan Danchev
    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mark
    Mark avatar
    90 posts
    Member since:
    Jul 2014

    Posted 13 Aug 2015 in reply to Ivan Danchev Link to this post

    Hi Ivan,

     Thanks for your reply and apologies for not getting back sooner.  Unfortunately I can't find the OnClientLoaded event you mentioned - although I am using a Kendo control for MVC with C# which makes it different??  If that event is available, please could you send me a very basic example where this event is implemented in MVC to work with - if it isn't available then please can you advise how this issue can be resolved using MVC?

     Many thanks, Mark

  5. Answer
    Ivan Danchev
    Admin
    Ivan Danchev avatar
    829 posts

    Posted 14 Aug 2015 Link to this post

    Hello Mark,

    If Kendo MVC controls are involved I suggest you start a new thread in the Kendo section of the forums. My colleagues supporting the Kendo products would be able to give advice on your scenario.

    Regards,
    Ivan Danchev
    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
  6. Mark
    Mark avatar
    90 posts
    Member since:
    Jul 2014

    Posted 17 Aug 2015 in reply to Ivan Danchev Link to this post

    Thanks Ivan, I'll try that.

    Mark

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