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

Trouble creating reusable JavaScript function to gather FullPath of TreeView

1 Answer 46 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Grumpwurst
Top achievements
Rank 1
Grumpwurst asked on 18 Jul 2012, 08:01 PM
I have followed the example I found on the Telerik site on how to create a string representing the full path of the "checked" node in the tree view.  This is working fabulously and the function is below:
function clientNodeChecked(sender, eventArgs) {
    var node = eventArgs.get_node();
    var s = node.get_text();
    var currentObject = node.get_parent();
    while (currentObject != null) {
        if (currentObject != node.get_treeView()) {
            s = currentObject.get_text() + " > " + s;
        }
        else {
            break;
        }
        currentObject = currentObject.get_parent();
    }
    var tbPath;
    tbPath = $get("<%= lblFullPath_InvGroupOwner.ClientID  %>");
    tbPath.innerHTML = s;
}

Well, I have many RadTreeView controls on my screen and throughout my application and I'm wanting to avoid writing a javascript per tree just so I can name the textbox control that is supposed to contain the Full Path string.

I will admit that I'm learning JavaScript in conjunction with learning the Telerik controls so this may be an obvious answer to a more experienced JavaScript developer, but what do I need to do in order to pass the ClientID to this method for the textbox I'm wanting to store the FullPath?

Sadly, there isn't a client-side version of the control's GetFullPath() method :(

Thanks in advance,
Ray

1 Answer, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 23 Jul 2012, 08:43 AM
Hello Ray,

 
I am attaching one way to achieve such functionality to work programmatically by setting the ids of the textboxes according to the appropriate RadTreeView and use jQuery to find them afterwards.

Hope this will be helpful.

Greetings,
Plamen
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.
Tags
TreeView
Asked by
Grumpwurst
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Share this question
or