Trouble creating reusable JavaScript function to gather FullPath of TreeView

2 posts, 0 answers
  1. Grumpwurst
    Grumpwurst avatar
    8 posts
    Member since:
    Jul 2012

    Posted 18 Jul 2012 Link to this post

    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
  2. Plamen
    Admin
    Plamen avatar
    2729 posts

    Posted 23 Jul 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top