RadDropDownTree Setting Alternate Selected Text

4 posts, 0 answers
  1. Marc Vanderveen
    Marc Vanderveen avatar
    3 posts
    Member since:
    Aug 2004

    Posted 09 Jan Link to this post

    Hello,

    I have a usercontrol with a single select DropDownTree where I need to display slightly different text than what is show as the node text.  This text is basically a more user readable form of the full path.  Currently I am storing that alternate text as node attributes attached server side:

        Dim newNodeL3 As New RadTreeNode(tr_row.BodyPartL3Text, tr_Body.BodyPartID)

    newNodeL3.Attributes("FullText") =  row_Body.BodyPartFullText

  2. Marc Vanderveen
    Marc Vanderveen avatar
    3 posts
    Member since:
    Aug 2004

    Posted 09 Jan in reply to Marc Vanderveen Link to this post

    Sorry, this was posted prematurely - creating the rest of the question now
  3. Marc Vanderveen
    Marc Vanderveen avatar
    3 posts
    Member since:
    Aug 2004

    Posted 09 Jan Link to this post

    continuing...

    I have no problem accessing and updating to the alternate text using a RadTreeView1_DropDownClosed client event, and I am doing so by updating the inner  HTML:

            
        var initialInnerHTML = sender.get_element().innerHTML;
        var adjustedInnerHTML = initialInnerHTML.replace(currentText, selectedFullTextString);
        sender.get_element().innerHTML = adjustedInnerHTML;

     

    but this is not working for me when the node is pre-selected server side because of course this event does not fire on page load.

    I've tried adding similar code to an OnClientLoad event and it shows the new value, but it seems to disable the drop down tree:

    selectedFullTextString = '<span class=\"rddtFakeInput\">' + treeView.get_selectedNode().get_attributes().getAttribute("FullText") + '</span>';
    var currentText = '<span class=\"rddtFakeInput\">' + sender._selectedText + '</span>';
    var initialInnerHTML = sender.get_element().innerHTML;
    var adjustedInnerHTML = initialInnerHTML.replace(currentText, selectedFullTextString);
    sender.get_element().innerHTML = adjustedInnerHTML;

     

    Here is a Data element to help conceptualize the issue:

    Tree Node L1 (Text:Arm) 

          Tree Node L2 (Text:Left)

               Tree Node L3 (Text:Hand)

    Full Path text would be Arm --> Left --> Hand and the selected Item text would be just 'Hand'.

    I am trying to show the custom value "Left Hand" that is stored as an attribute on the L3 Node. Any suggestions? 

    Thanks!

    Marc Vanderveen

     

     

     

     

  4. Ivan Danchev
    Admin
    Ivan Danchev avatar
    993 posts

    Posted 12 Jan Link to this post

    Hello Marc,

    If you want to change the text of a node that is pre-selected on the server you can do so in the DropDownTree's OnClientLoad event handler as demonstrated in the code snippet below, using the RadDropDownTree, the embedded RadTreeView and the RadTreeNode client side objects' methods:
    <script type="text/javascript">
        function OnClientLoad(sender) {
            var tree = sender.get_embeddedTree();
            var selectedNode = tree.get_selectedNode();
            if (selectedNode) {
                var parent = selectedNode.get_parent();
                //the following check ensures the selected node is not a Root node
                if (parent != tree) {
                    var oldText = selectedNode.get_text();
                    var newText = parent.get_text() + "-->" + oldText;
                    selectedNode.set_text(newText);
                }
            };
        }
    </script>


    Regards,
    Ivan Danchev
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top