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

FindNodeByText - Couple of Questions

1 Answer 34 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Silver
Top achievements
Rank 1
Silver asked on 21 May 2012, 10:37 PM
HI,

I provided a textbox for user to find tree view nodes. The find functionality is working good, but I have couple of questions

1. After node.expand() and node.select(), how to make the tree view to load a page which is tied to that node. Each node on my tree view has NavigateURL set to a aspx page.

2. Is there a way to find the node based on partial value entered? For example if node text is 'Employee Engagements', I want to find the node if user enters 'Employee' or 'Engagements'.. I mean like text.contains..

Thanks

1 Answer, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 24 May 2012, 03:54 PM
Hello Silver,

 
1.You can navigate to the URL of some node as it is done in this code:

function OnClient(sender, args) {
          var treeOne = $find("<%= RadTreeView1.ClientID %>");
       window.location=treeOne.get_nodes().getNode(0).get_navigateUrl();
        }
 
2.Here is that code  that shows how to go through all the nodes and select all the files that contain some text:
function OnClientClicked(sender, args) {
              var textBox = $find("<%= RadTextBox1.ClientID %>");
             var treeOne = $find("<%= RadTreeView1.ClientID %>");
            
              for (var i = 0; i < treeOne.get_allNodes().length; i++) {
               
                    if (treeOne.get_allNodes()[i].get_text().indexOf(textBox.get_value()) !=-1) {
 
                       treeOne.get_allNodes()[i].select(true);
                    }
                }
            }
        </script>
        <telerik:RadTextBox runat="server" ID="RadTextBox1">
        </telerik:RadTextBox>
         <telerik:RadButton runat="server" ID="RadButton1" AutoPostBack="false" Text="Select Nodes"
            OnClientClicked="OnClientClicked">
        </telerik:RadButton>
       <telerik:RadButton runat="server" ID="RadButton2" AutoPostBack="false" Text="Navigate"
            OnClientClicked="OnClient">
        </telerik:RadButton>
        <telerik:RadTreeView runat="server" ID="RadTreeView1" MultipleSelect="true">...

Hope this will help you.

All the best,
Plamen Zdravkov
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
Silver
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Share this question
or