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

Treeview expand down to selected node on load and click

4 Answers 345 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 04 Aug 2015, 10:12 AM

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

4 Answers, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 07 Aug 2015, 08:17 AM
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
0
Mark
Top achievements
Rank 1
answered on 13 Aug 2015, 12:04 PM

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

0
Accepted
Ivan Danchev
Telerik team
answered on 14 Aug 2015, 01:59 PM
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
0
Mark
Top achievements
Rank 1
answered on 17 Aug 2015, 08:23 AM

Thanks Ivan, I'll try that.

Mark

Tags
TreeView
Asked by
Mark
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Mark
Top achievements
Rank 1
Share this question
or