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

Clientside select of TreeView node

2 Answers 103 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
David
Top achievements
Rank 1
David asked on 24 Oct 2011, 08:39 PM
I have an ASP.NET MVC 3 Razor application.  From the Telerik Extensions I'm using the Telerik TreeView.  I've created a breadcrumb path, that when clicked, makes an Ajax POST and pulls/displays the appropriate data.  The last thing I need to figure out is how to de-highlight the previously selected TreeView node and highlight the TreeView node associated with the selected breadcrumb.  Can someone point me in the right direction?
Thank you.

2 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 25 Oct 2011, 08:03 AM
Hi David,

The TreeView selection is purely visual and implies appending a "t-state-selected" CSS class to the <span class="t-in"> element, which is inside the TreeView item wrapper - a <li class="t-item"> element.

Greetings,
Dimo
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 Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
David
Top achievements
Rank 1
answered on 25 Oct 2011, 03:24 PM

Thanks for your help.
Specifically I found the following to work for me.

function onClickFollowBreadcrumb(e) {
    var treeview = $("#TheTreeView").data("tTreeView");
    // To clear any "selected" node:
    $(".t-state-selected", treeview.element).removeClass('t-state-selected');
    // Get the node based upon what part of the breadcrumb was selected.
    var findString = ".t-input[name='itemValue'][value='" + e + "']";
    var item = $("#TheTreeView").find(findString).closest("li");
    // Programmatically "click" the desired node.
    item.find(".t-in:first").trigger("click");
    return true;
}
Tags
General Discussions
Asked by
David
Top achievements
Rank 1
Answers by
Dimo
Telerik team
David
Top achievements
Rank 1
Share this question
or