Search Nodes (clientSide)

5 posts, 0 answers
  1. Mehrdad
    Mehrdad avatar
    9 posts
    Member since:
    Mar 2009

    Posted 03 Mar 2009 Link to this post

    Hi.
    I  want to search tree nodes (by name), and select the math node.
    How could I do this clientSide?
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 03 Mar 2009 Link to this post

    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.
  3. Mehrdad
    Mehrdad avatar
    9 posts
    Member since:
    Mar 2009

    Posted 03 Mar 2009 Link to this post

    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)
  4. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 04 Mar 2009 Link to this post

    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.
  5. Mehrdad
    Mehrdad avatar
    9 posts
    Member since:
    Mar 2009

    Posted 04 Mar 2009 Link to this post

    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(....
Back to Top