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

How to find and expand RadTree node

3 Answers 150 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Svetlana
Top achievements
Rank 1
Svetlana asked on 30 Jun 2010, 01:40 PM
Hello,

I need to select a node and subnode in RadTree. The node's name may have different values on each test running.

Example:
<div id="ctl00_CP_treeGroups" class="RadTreeView RadTreeView_Office2007">
    <ul class="rtUL rtLines">
        <li class="rtLI rtFirst">
            <div class="rtTop rtSelected">
                <span class="rtSp"></span><span class="rtMinus"></span>
                <span
                    class="rtIn">All items (278)</span>
            </div>
            <ul class="rtUL">
                <li class="rtLI">
                    <div class="rtTop">
                        <span class="rtSp"></span><span class="rtPlus"></span>
                        <span
                            class="rtIn">Node1 (62)</span>
                    </div>
                    <ul class="rtUL" style="display: none;">
                        <li class="rtLI">
                            <div class="rtTop">
                                <span class="rtSp"></span>
                                <span class="rtIn">SubNode11 (3)</span>
                            </div>
                        </li>
                        <li class="rtLI rtLast">
                            <div class="rtBot">
                                <span class="rtSp"></span>
                                <img src="../../../../Images/Icons/group_16.png" alt="" class="rtImg"><span class="rtIn">SubNode12
                                    (2)</span>
                            </div>
                        </li>
                    </ul>
                </li>
                <li class="rtLI">
                    <div class="rtMid">
                        <span class="rtSp"></span><span class="rtPlus"></span>
                       <span
                            class="rtIn">Node2 (20)</span>
                    </div>
                    <ul class="rtUL" style="display: none;">
                        <li class="rtLI rtLast">
                            <div class="rtBot">
                                <span class="rtSp"></span>
                                <img src="../../../../Images/Icons/group_16.png" alt="" class="rtImg"><span class="rtIn">SubNode21 (1)</span>
                            </div>
                        </li>
                    </ul>
                </li>
    </ul>
    <input value="{&quot;expandedNodes&quot;:[],&quot;collapsedNodes&quot;:[],&quot;logEntries&quot;:[],&quot;selectedNodes&quot;:[&quot;0&quot;],&quot;checkedNodes&quot;:[],&quot;scrollPosition&quot;:0}"
        autocomplete="off" id="ctl00_CP_treeGroups_ClientState" name="ctl00_CP_treeGroups_ClientState"
        type="hidden">
</div>

Could you, please, give an example how to find and select 'Node2' and 'SubNode11' and expand a node?

Thanks,
Svetlana

3 Answers, 1 is accepted

Sort by
0
Helen
Telerik team
answered on 02 Jul 2010, 02:43 PM
Hi Svetlana,

Please find a test method below which shows how to achieve  this:

[TestMethod]
 
public void NodeExpand()
{
    Manager.LaunchNewBrowser();
    ActiveBrowser.NavigateTo("YourPage.aspx");
 
    RadTreeView tree1 = Find.ById<RadTreeView>("ctl00_CP_treeGroups");
     
    //finds all level 1 nodes (Node1 and Node2)
    IList<RadTreeNode> firstLevelNodes = tree.FindNode(node => node.Level == 1);
     
     
    RadTreeNode node2 = firstLevelNodes[1];
    node2.expand();
     
    RadTreeNode node11 = firstLevelNodes[0].Nodes[0];
    node11.select();
     
     
}

Hope this helps.

Regards,
Helen
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Svetlana
Top achievements
Rank 1
answered on 05 Jul 2010, 02:21 PM
Hello Helen,

Thank you for the example. But can I use nodes' names instead of indexes?

Regards,
Svetlana
0
Helen
Telerik team
answered on 06 Jul 2010, 12:07 PM
Hello Svetlana,

If nodes names are static you can use the FindNodeByText method.

Regards,
Helen
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
Svetlana
Top achievements
Rank 1
Answers by
Helen
Telerik team
Svetlana
Top achievements
Rank 1
Share this question
or