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

Search Nodes (clientSide)

4 Answers 191 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Mehrdad
Top achievements
Rank 1
Mehrdad asked on 03 Mar 2009, 12:55 PM
Hi.
I  want to search tree nodes (by name), and select the math node.
How could I do this clientSide?

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 03 Mar 2009, 01:09 PM

Hi Mehrdad,

Once you get the client-side object of RadTreeView, you can use findNodeByText() method to get the instance of a particular Node (if want to search by name). Try the following client side code for getting the node and selecting that.

JavaScript:

<script type="text/javascript">  
function selectNode()  
{  
   var treeView = $find("<%= RadTreeView1.ClientID %>");         
   var node = treeView.findNodeByText("Node1");  
   node.select();  
}  
</script> 
Check out the following link for more information about Client-Side Programming Basics

Thanks,
Princy.
0
Mehrdad
Top achievements
Rank 1
answered on 03 Mar 2009, 01:15 PM
Dear Princy, two other questions please:
1. where can I find menmers (methods and properties) of a RadControl (client and server side)
2. How can I do search by matching the menu text not exact, for example if I have a node with text: "Number", by enterig "umb" it be found? (i.e. while Cards)
0
Princy
Top achievements
Rank 2
answered on 04 Mar 2009, 06:26 AM
Hello Mehrdad,

I tried following client side code for searching and selecting node. Try the following code snippet and see whether its fit for your need.

JavaScript:
<script type="text/javascript">  
function searchNode()  
{  
    var treeView = $find("<%= RadTreeView1.ClientID %>");  
    var node = treeView.findNodeByText('Root');  
    search(node);    //Call function by passing the root node  
}  
function search(node)  
{  
    var i;  
    var str= node.get_text();  
    if(str.match("umb")!=null)  //Compare with the search term  
    {  
        node.select();  
        return;  
    }  
    else 
    {  
        if(node._hasChildren())  
        {  
            for(i= 0; i<node._getChildren().get_count();i++)  
            {  
                search(node._children._array[i]);  
            }  
        }  
        else 
            return;  
    }  
}  
</script> 

Checkout the following links.
Server-Side Events
Server-Side Programming Basics

Go through the link for most important functions of the RadTreeNode client side object and client side events.
RadTreeNode
Client-Side Events

Thanks,
Princy.
0
Mehrdad
Top achievements
Rank 1
answered on 04 Mar 2009, 08:50 AM
A problem!
I have put the treeview in a usercontrol, and an object expected error occures in my code. it can't find a control with the name returned by $find(....
Tags
TreeView
Asked by
Mehrdad
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Mehrdad
Top achievements
Rank 1
Share this question
or