Expand Treeview node based on bowser URL - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

Expand Treeview node based on bowser URL

  • Expand Treeview node based on bowser URL
  • Hi

    How can i expand the node based on the page url.

    I'm using the treeview in sharepoint using sitemap datasource.
    want to expand the node based on the site/ sub site and in the expanded node it should be selected child node based on the pagename


    Thanks
    Arun
  • Hello Arunkumar,

    There is a method set_expand() that you can use.

    sample

    function pageLoad()
        var tree = $find("<%= RadTreeview1.ClientID %>");
        if (tree)
            var location = window.location.pathname;
            location = location.substring(location.lastIndexOf('/') + 1);
            var nodeText = location.split('.');
            var currentNode = tree.findNodeByText(nodeText[0]);
            if (currentNode)
                currentNode.set_expanded(true);
            
        


    All the best,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  • while using the code i got the following error

    The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)

    sorry for the cause im very new to Telerik controls, forgive me if i did anything wrong.

    Here is my code


     

    <FONT color=#0000ff size=2><FONT color=#0000ff size=2
    <P><</FONT></FONT><FONT color=#a31515 size=2>head</FONT><FONT size=2
    </FONT><FONT color=#ff0000 size=2>runat</FONT><FONT color=#0000ff 
    size=2>="server"> </P>
    <P>
    <P> </FONT><FONT color=#0000ff size=2><</FONT><FONT color=#a31515 
    size=2>title</FONT><FONT color=#0000ff size=2>></</FONT><FONT 
    color=#a31515 size=2>title</FONT><FONT color=#0000ff 
    size=2>>  </P></P></FONT>
    <P></P>
    <P><FONT color=#0000ff size=2><</FONT><FONT color=#a31515 
    size=2>link</FONT><FONT size=2> </FONT><FONT color=#ff0000 
    size=2>href</FONT><FONT color=#0000ff 
    size=2>="IV/TreeView.Windows7.css"</FONT><FONT size=2> </FONT><FONT 
    color=#ff0000 size=2>rel</FONT><FONT color=#0000ff 
    size=2>="stylesheet"</FONT><FONT size=2> </FONT><FONT color=#ff0000 
    size=2>type</FONT><FONT color=#0000ff size=2>="text/css"</FONT><FONT size=2
    </FONT><FONT color=#0000ff size=2>/> 
    <P></FONT><FONT color=#0000ff size=2><</FONT><FONT color=#a31515 
    size=2>script</FONT><FONT size=2> </FONT><FONT color=#ff0000 
    size=2>language</FONT><FONT color=#0000ff 
    size=2>="javascript"> </FONT><FONT size=2> </P></P></FONT>
    <P><FONT color=#0000ff size=2>function</FONT><FONT size=2> onLoad(sender, 
    eventArgs)  
    <P></FONT><FONT color=#0000ff size=2>var</FONT><FONT size=2> zeroNode = 
    sender.get_allNodes()[0]; </P>
    <P>
    <P></FONT><FONT color=#0000ff size=2>if</FONT><FONT size=2
    (zeroNode.get_nodes().get_count() > 0) </P>
    <P>
    <P>zeroNode.expand();</P>
    <P></P>
    <P></P></FONT>
    <P></P><FONT color=#0000ff size=2><FONT color=#0000ff size=2
    <P>function</FONT></FONT><FONT size=2>ClientNodeClicked(sender, eventArgs) </P>
    <P>
    <P> </P></FONT>
    <P></P>
    <P><FONT color=#0000ff size=2>var</FONT><FONT size=2> node = 
    eventArgs.get_node(); 
    <P> node.toggle();</P>
    <P></P>
    <P>functionpageLoad()</P>
    <P></P>
    <P>vartree = $find(</FONT><FONT color=#a31515 size=2>"<%= 
    RadTreeView1.ClientID %>"</FONT><FONT size=2>); </P>
    <P>
    <P> </FONT><FONT color=#0000ff size=2>if</FONT><FONT size=2>(tree) 
      </P>
    <P>
    <P>varlocation = window.location.pathname;</P>
    <P>location = location.substring(location.lastIndexOf(</P></FONT>
    <P></P>
    <P><FONT color=#a31515 size=2>'/'</FONT><FONT size=2>) + 1); 
    <P> varnodeText = location.split(</P></FONT>
    <P></P>
    <P><FONT color=#a31515 size=2>'.'</FONT><FONT size=2>); 
    <P> varcurrentNode = tree.findNodeByText(nodeText[0]);</P>
    <P> </FONT><FONT color=#0000ff size=2>if</FONT><FONT size=2>(currentNode)  
    </P>
    <P>
    <P> currentNode.set_expanded(</P></FONT>
    <P></P>
    <P><FONT color=#0000ff size=2>true</FONT><FONT size=2>); 
    <P> </P>
    <P></P>
    <P></P></FONT>
    <P></P><FONT color=#0000ff size=2><FONT color=#0000ff size=2
    </</FONT></FONT><FONT color=#a31515 size=2>script</FONT><FONT color=#0000ff 
    size=2><FONT color=#0000ff size=2>> 
    <P>
    <P></</FONT></FONT><FONT color=#a31515 size=2>head</FONT><FONT color=#0000ff 
    size=2><FONT color=#0000ff size=2>> </P>
    <P>
    <P> <</FONT></FONT><FONT color=#a31515 size=2>body</FONT><FONT 
    color=#0000ff size=2>> </P>
    <P>
    <P> </FONT><FONT color=#0000ff size=2><</FONT><FONT color=#a31515 
    size=2>form</FONT><FONT size=2> </FONT><FONT color=#ff0000 size=2>id</FONT><FONT 
    color=#0000ff size=2>="form1"</FONT><FONT size=2> </FONT><FONT color=#ff0000 
    size=2>runat</FONT><FONT color=#0000ff size=2>="server"> </P>
    <P>
    <P> </FONT><FONT color=#0000ff size=2><</FONT><FONT color=#a31515 
    size=2>telerik</FONT><FONT color=#0000ff size=2>:</FONT><FONT color=#a31515 
    size=2>RadScriptManager</FONT><FONT size=2> </FONT><FONT color=#ff0000 
    size=2>runat</FONT><FONT color=#0000ff size=2>="server"</FONT><FONT size=2
    </FONT><FONT color=#ff0000 size=2>ID</FONT><FONT color=#0000ff 
    size=2>="RadScriptManager1"</FONT><FONT size=2> </FONT><FONT color=#0000ff 
    size=2>/> </P>
    <P>
    <P> </FONT><FONT color=#0000ff size=2><</FONT><FONT color=#a31515 
    size=2>telerik</FONT><FONT color=#0000ff size=2>:</FONT><FONT color=#a31515 
    size=2>RadTreeView</FONT><FONT size=2> </FONT><FONT color=#ff0000 
    size=2>ID</FONT><FONT color=#0000ff size=2>="RadTreeView1"</FONT><FONT size=2
    </FONT><FONT color=#ff0000 size=2>EnableEmbeddedSkins</FONT><FONT color=#0000ff 
    size=2>="false"</FONT><FONT size=2> </FONT><FONT color=#ff0000 
    size=2>DataSourceID</FONT><FONT color=#0000ff size=2>="XmlDataSource1" </P>
    <P>
    <P> </FONT><FONT color=#ff0000 size=2>runat</FONT><FONT color=#0000ff 
    size=2>="server"</FONT><FONT size=2> </FONT><FONT color=#ff0000 
    size=2>Skin</FONT><FONT color=#0000ff size=2>="IV"</FONT><FONT size=2
    </FONT><FONT color=#ff0000 size=2>OnClientLoad</FONT><FONT color=#0000ff 
    size=2>="onLoad"</FONT><FONT size=2> </FONT><FONT color=#ff0000 
    size=2>OnClientNodeClicked</FONT><FONT color=#0000ff 
    size=2>="ClientNodeClicked"</FONT><FONT size=2> </FONT><FONT color=#ff0000 
    size=2>DataNavigateUrlField</FONT><FONT color=#0000ff 
    size=2>="ImageUrl"</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>> 
    </P>
    <P>
    <P> </FONT><FONT color=#0000ff size=2><</FONT><FONT color=#a31515 
    size=2>DataBindings</FONT><FONT color=#0000ff size=2>> </P>
    <P>
    <P> </FONT><FONT color=#0000ff size=2><</FONT><FONT color=#a31515 
    size=2>telerik</FONT><FONT color=#0000ff size=2>:</FONT><FONT color=#a31515 
    size=2>RadTreeNodeBinding</FONT><FONT size=2> </FONT><FONT color=#ff0000 
    size=2>SelectedImageUrl</FONT><FONT color=#0000ff 
    size=2>="Img/selected_arrow.png"</FONT><FONT size=2> </FONT><FONT color=#ff0000 
    size=2>ExpandMode</FONT><FONT color=#0000ff size=2>="ClientSide"</FONT><FONT 
    size=2> </FONT><FONT color=#ff0000 size=2>DataMember</FONT><FONT color=#0000ff 
    size=2>="Node"</FONT><FONT size=2> </FONT><FONT color=#ff0000 
    size=2>TextField</FONT><FONT color=#0000ff size=2>="Text"</FONT><FONT size=2
    </FONT><FONT color=#ff0000 size=2>ExpandedField</FONT><FONT color=#0000ff 
    size=2>="Expanded"</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>/> 
    </P>
    <P>
    <P> </FONT><FONT color=#0000ff size=2></</FONT><FONT color=#a31515 
    size=2>DataBindings</FONT><FONT color=#0000ff size=2>> </FONT><FONT 
    size=2> </P></P></FONT>
    <P><FONT color=#0000ff size=2></</FONT><FONT color=#a31515 
    size=2>telerik</FONT><FONT color=#0000ff size=2>:</FONT><FONT color=#a31515 
    size=2>RadTreeView</FONT><FONT color=#0000ff size=2>> 
    <P></FONT><FONT color=#0000ff size=2><</FONT><FONT color=#a31515 
    size=2>asp</FONT><FONT color=#0000ff size=2>:</FONT><FONT color=#a31515 
    size=2>XmlDataSource</FONT><FONT size=2> </FONT><FONT color=#ff0000 
    size=2>runat</FONT><FONT color=#0000ff size=2>="server"</FONT><FONT size=2
    </FONT><FONT color=#ff0000 size=2>ID</FONT><FONT color=#0000ff 
    size=2>="XmlDataSource1"</FONT><FONT size=2> </FONT><FONT color=#ff0000 
    size=2>DataFile</FONT><FONT color=#0000ff size=2>="TreeView.xml"</FONT><FONT 
    size=2> </FONT><FONT color=#ff0000 size=2>XPath</FONT><FONT color=#0000ff 
    size=2>="/Tree/Node"</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>/> 
    </P>
    <P> <</FONT><FONT color=#0000ff size=2>/</FONT><FONT color=#a31515 
    size=2>form</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>> 
    <BR></</FONT></FONT><FONT color=#a31515 size=2>body</FONT><FONT color=#0000ff 
    size=2>><BR></FONT></P>

    and the xml file contains the following code

     

    <P><FONT color=#0000ff size=2><FONT color=#0000ff 
    size=2><?</FONT></FONT><FONT color=#a31515 size=2>xml</FONT><FONT 
    color=#0000ff size=2> </FONT><FONT color=#ff0000 size=2>version</FONT><FONT 
    color=#0000ff size=2>=</FONT><FONT size=2>"</FONT><FONT color=#0000ff 
    size=2>1.0</FONT><FONT size=2>"</FONT><FONT color=#0000ff size=2> </FONT><FONT 
    color=#ff0000 size=2>encoding</FONT><FONT color=#0000ff size=2>=</FONT><FONT 
    size=2>"</FONT><FONT color=#0000ff size=2>utf-8</FONT><FONT size=2>"</FONT><FONT 
    color=#0000ff size=2><FONT color=#0000ff size=2> ?> </P>
    <P>
    <P>
    <P> <</FONT></FONT><FONT color=#a31515 size=2>Tree</FONT><FONT 
    color=#0000ff size=2><FONT color=#0000ff size=2>> </P>
    <P>
    <P> <</FONT></FONT><FONT color=#a31515 size=2>Node</FONT><FONT 
    color=#0000ff size=2> </FONT><FONT color=#ff0000 size=2>Text</FONT><FONT 
    color=#0000ff size=2>=</FONT><FONT size=2>"</FONT><FONT color=#0000ff 
    size=2>Media Center</FONT><FONT size=2>"</FONT><FONT color=#0000ff size=2
    </FONT><FONT color=#ff0000 size=2>ImageUrl</FONT><FONT color=#0000ff 
    size=2>=</FONT><FONT size=2>""</FONT><FONT color=#0000ff size=2> </FONT><FONT 
    color=#ff0000 size=2>Expanded</FONT><FONT color=#0000ff size=2>=</FONT><FONT 
    size=2>"</FONT><FONT color=#0000ff size=2>False</FONT><FONT size=2>"</FONT><FONT 
    color=#0000ff size=2><FONT color=#0000ff size=2>> </P>
    <P>
    <P> <</FONT></FONT><FONT color=#a31515 size=2>Node</FONT><FONT 
    color=#0000ff size=2> </FONT><FONT color=#ff0000 size=2>Text</FONT><FONT 
    color=#0000ff size=2>=</FONT><FONT size=2>"</FONT><FONT color=#0000ff 
    size=2>Press Release</FONT><FONT size=2>"</FONT><FONT color=#0000ff size=2
    </FONT><FONT color=#ff0000 size=2>ImageUrl</FONT><FONT color=#0000ff 
    size=2>=</FONT><FONT size=2>""</FONT><FONT color=#0000ff size=2><FONT 
    color=#0000ff size=2>> </P>
    <P>
    <P> <</FONT></FONT><FONT color=#a31515 size=2>Node</FONT><FONT 
    color=#0000ff size=2> </FONT><FONT color=#ff0000 size=2>Text</FONT><FONT 
    color=#0000ff size=2>=</FONT><FONT size=2>"</FONT><FONT color=#0000ff 
    size=2>AppData</FONT><FONT size=2>"</FONT><FONT color=#0000ff size=2
    </FONT><FONT color=#ff0000 size=2>ImageUrl</FONT><FONT color=#0000ff 
    size=2>=</FONT><FONT size=2>""</FONT><FONT color=#0000ff size=2><FONT 
    color=#0000ff size=2>> </P>
    <P>
    <P> <</FONT></FONT><FONT color=#a31515 size=2>Node</FONT><FONT 
    color=#0000ff size=2> </FONT><FONT color=#ff0000 size=2>Text</FONT><FONT 
    color=#0000ff size=2>=</FONT><FONT size=2>"</FONT><FONT color=#0000ff 
    size=2>Microsoft</FONT><FONT size=2>"</FONT><FONT color=#0000ff size=2
    </FONT><FONT color=#ff0000 size=2>ImageUrl</FONT><FONT color=#0000ff 
    size=2>=</FONT><FONT size=2>"</FONT><FONT color=#0000ff 
    size=2>Default3.aspx</FONT><FONT size=2>"</FONT><FONT color=#0000ff size=2><FONT 
    color=#0000ff size=2>/> </P>
    <P>
    <P> </</FONT></FONT><FONT color=#a31515 size=2>Node</FONT><FONT 
    color=#0000ff size=2><FONT color=#0000ff size=2>> </P>
    <P>
    <P> <</FONT></FONT><FONT color=#a31515 size=2>Node</FONT><FONT 
    color=#0000ff size=2> </FONT><FONT color=#ff0000 size=2>Text</FONT><FONT 
    color=#0000ff size=2>=</FONT><FONT size=2>"</FONT><FONT color=#0000ff 
    size=2>Contacts</FONT><FONT size=2>"</FONT><FONT color=#0000ff size=2
    </FONT><FONT color=#ff0000 size=2>ImageUrl</FONT><FONT color=#0000ff 
    size=2>=</FONT><FONT size=2>""</FONT><FONT color=#0000ff size=2><FONT 
    color=#0000ff size=2>/> </P>
    <P>
    <P> <</FONT></FONT><FONT color=#a31515 size=2>Node</FONT><FONT 
    color=#0000ff size=2> </FONT><FONT color=#ff0000 size=2>Text</FONT><FONT 
    color=#0000ff size=2>=</FONT><FONT size=2>"</FONT><FONT color=#0000ff 
    size=2>Downloads</FONT><FONT size=2>"</FONT><FONT color=#0000ff size=2
    </FONT><FONT color=#ff0000 size=2>ImageUrl</FONT><FONT color=#0000ff 
    size=2>=</FONT><FONT size=2>""</FONT><FONT color=#0000ff size=2><FONT 
    color=#0000ff size=2> /> </P>
    <P>
    <P> <</FONT></FONT><FONT color=#a31515 size=2>Node</FONT><FONT 
    color=#0000ff size=2> </FONT><FONT color=#ff0000 size=2>Text</FONT><FONT 
    color=#0000ff size=2>=</FONT><FONT size=2>"</FONT><FONT color=#0000ff 
    size=2>Documents</FONT><FONT size=2>"</FONT><FONT color=#0000ff size=2
    </FONT><FONT color=#ff0000 size=2>ImageUrl</FONT><FONT color=#0000ff 
    size=2>=</FONT><FONT size=2>""</FONT><FONT color=#0000ff size=2><FONT 
    color=#0000ff size=2>/> </P>
    <P>
    <P> <</FONT></FONT><FONT color=#a31515 size=2>Node</FONT><FONT 
    color=#0000ff size=2> </FONT><FONT color=#ff0000 size=2>Text</FONT><FONT 
    color=#0000ff size=2>=</FONT><FONT size=2>"</FONT><FONT color=#0000ff 
    size=2>Press Coverage</FONT><FONT size=2>"</FONT><FONT color=#0000ff size=2
    </FONT><FONT color=#ff0000 size=2>ImageUrl</FONT><FONT color=#0000ff 
    size=2>=</FONT><FONT size=2>""</FONT><FONT color=#0000ff size=2><FONT 
    color=#0000ff size=2> > </P>
    <P>
    <P> <</FONT></FONT><FONT color=#a31515 size=2>Node</FONT><FONT 
    color=#0000ff size=2> </FONT><FONT color=#ff0000 size=2>Text</FONT><FONT 
    color=#0000ff size=2>=</FONT><FONT size=2>"</FONT><FONT color=#0000ff 
    size=2>Archives</FONT><FONT size=2>"</FONT><FONT color=#0000ff size=2
    </FONT><FONT color=#ff0000 size=2>ImageUrl</FONT><FONT color=#0000ff 
    size=2>=</FONT><FONT size=2>""</FONT><FONT color=#0000ff size=2><FONT 
    color=#0000ff size=2> /> </P>
    <P>
    <P> </</FONT></FONT><FONT color=#a31515 size=2>Node</FONT><FONT 
    color=#0000ff size=2><FONT color=#0000ff size=2>> </P>
    <P>
    <P><</FONT></FONT><FONT color=#a31515 size=2>Node</FONT><FONT color=#0000ff 
    size=2> </FONT><FONT color=#ff0000 size=2>Text</FONT><FONT color=#0000ff 
    size=2>=</FONT><FONT size=2>"</FONT><FONT color=#0000ff size=2>Music</FONT><FONT 
    size=2>"</FONT><FONT color=#0000ff size=2> </FONT><FONT color=#ff0000 
    size=2>ImageUrl</FONT><FONT color=#0000ff size=2>=</FONT><FONT 
    size=2>""</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2> /> 
    </P>
    <P>
    <P> <</FONT></FONT><FONT color=#a31515 size=2>Node</FONT><FONT 
    color=#0000ff size=2> </FONT><FONT color=#ff0000 size=2>Text</FONT><FONT 
    color=#0000ff size=2>=</FONT><FONT size=2>"</FONT><FONT color=#0000ff 
    size=2>Pictures</FONT><FONT size=2>"</FONT><FONT color=#0000ff size=2
    </FONT><FONT color=#ff0000 size=2>ImageUrl</FONT><FONT color=#0000ff 
    size=2>=</FONT><FONT size=2>""</FONT><FONT color=#0000ff size=2><FONT 
    color=#0000ff size=2> /> </P>
    <P>
    <P> <</FONT></FONT><FONT color=#a31515 size=2>Node</FONT><FONT 
    color=#0000ff size=2> </FONT><FONT color=#ff0000 size=2>Text</FONT><FONT 
    color=#0000ff size=2>=</FONT><FONT size=2>"</FONT><FONT color=#0000ff 
    size=2>Saved Games</FONT><FONT size=2>"</FONT><FONT color=#0000ff size=2
    </FONT><FONT color=#ff0000 size=2>ImageUrl</FONT><FONT color=#0000ff 
    size=2>=</FONT><FONT size=2>""</FONT><FONT color=#0000ff size=2><FONT 
    color=#0000ff size=2> /> </P>
    <P>
    <P> <</FONT></FONT><FONT color=#a31515 size=2>Node</FONT><FONT 
    color=#0000ff size=2> </FONT><FONT color=#ff0000 size=2>Text</FONT><FONT 
    color=#0000ff size=2>=</FONT><FONT size=2>"</FONT><FONT color=#0000ff 
    size=2>Videos</FONT><FONT size=2>"</FONT><FONT color=#0000ff size=2
    </FONT><FONT color=#ff0000 size=2>ImageUrl</FONT><FONT color=#0000ff 
    size=2>=</FONT><FONT size=2>""</FONT><FONT color=#0000ff size=2><FONT 
    color=#0000ff size=2>/> </P>
    <P>
    <P> </</FONT></FONT><FONT color=#a31515 size=2>Node</FONT><FONT 
    color=#0000ff size=2><FONT color=#0000ff size=2>> </P>
    <P>
    <P> <</FONT></FONT><FONT color=#a31515 size=2>Node</FONT><FONT 
    color=#0000ff size=2> </FONT><FONT color=#ff0000 size=2>Text</FONT><FONT 
    color=#0000ff size=2>=</FONT><FONT size=2>"</FONT><FONT color=#0000ff 
    size=2>Press Coverage</FONT><FONT size=2>"</FONT><FONT color=#0000ff size=2
    </FONT><FONT color=#ff0000 size=2>ImageUrl</FONT><FONT color=#0000ff 
    size=2>=</FONT><FONT size=2>""</FONT><FONT color=#0000ff size=2><FONT 
    color=#0000ff size=2> > </P>
    <P>
    <P> <</FONT></FONT><FONT color=#a31515 size=2>Node</FONT><FONT 
    color=#0000ff size=2> </FONT><FONT color=#ff0000 size=2>Text</FONT><FONT 
    color=#0000ff size=2>=</FONT><FONT size=2>"</FONT><FONT color=#0000ff 
    size=2>Archives</FONT><FONT size=2>"</FONT><FONT color=#0000ff size=2
    </FONT><FONT color=#ff0000 size=2>ImageUrl</FONT><FONT color=#0000ff 
    size=2>=</FONT><FONT size=2>""</FONT><FONT color=#0000ff size=2><FONT 
    color=#0000ff size=2>/> </P>
    <P>
    <P> </</FONT></FONT><FONT color=#a31515 size=2>Node</FONT><FONT 
    color=#0000ff size=2><FONT color=#0000ff size=2>> </P>
    <P>
    <P> <</FONT></FONT><FONT color=#a31515 size=2>Node</FONT><FONT 
    color=#0000ff size=2> </FONT><FONT color=#ff0000 size=2>Text</FONT><FONT 
    color=#0000ff size=2>=</FONT><FONT size=2>"</FONT><FONT color=#0000ff 
    size=2>Speaches and Writings</FONT><FONT size=2>"</FONT><FONT color=#0000ff 
    size=2> </FONT><FONT color=#ff0000 size=2>ImageUrl</FONT><FONT color=#0000ff 
    size=2>=</FONT><FONT size=2>""</FONT><FONT color=#0000ff size=2><FONT 
    color=#0000ff size=2> > </P>
    <P>
    <P> <</FONT></FONT><FONT color=#a31515 size=2>Node</FONT><FONT 
    color=#0000ff size=2> </FONT><FONT color=#ff0000 size=2>Text</FONT><FONT 
    color=#0000ff size=2>=</FONT><FONT size=2>"</FONT><FONT color=#0000ff 
    size=2>Archives</FONT><FONT size=2>"</FONT><FONT color=#0000ff size=2
    </FONT><FONT color=#ff0000 size=2>ImageUrl</FONT><FONT color=#0000ff 
    size=2>=</FONT><FONT size=2>""</FONT><FONT color=#0000ff size=2><FONT 
    color=#0000ff size=2>/> </P>
    <P>
    <P> </</FONT></FONT><FONT color=#a31515 size=2>Node</FONT><FONT 
    color=#0000ff size=2><FONT color=#0000ff size=2>> </P>
    <P>
    <P> </</FONT></FONT><FONT color=#a31515 size=2>Node</FONT><FONT 
    color=#0000ff size=2><FONT color=#0000ff size=2>> </P>
    <P>
    <P> </</FONT></FONT><FONT color=#a31515 size=2>Tree</FONT><FONT 
    color=#0000ff size=2>> </P>
    <P>
    <P> </P></P></FONT></P>

     

     

  • Hi Arunkumar,

    Wrap the javascript inside RadcodeBlock control.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  • Thanks for your reply, i'm very sigh to say this im very new to this control,
    pls check the following code to do need full to complete my task

    COde in .aspx Page

    <body>
        <form id="form1" runat="server">
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script language="javascript" type="text/javascript">
            function pageLoad()
                var tree = $find("<%= RadTreeView1.ClientID %>");
                if (tree)
                    var location = window.location.pathname;
                    alert(location);
                    location = location.substring(location.lastIndexOf('/') + 1);
                    alert(location);
                    var nodeText = location.split('.');
                    alert(nodeText);
                    var currentNode = tree.findNodeByText(nodeText[0]);
                    alert(currentNode);
                    if (currentNode)
                        currentNode.set_expanded(true);
                    
                
            
       </script>
    </telerik:RadCodeBlock
         <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
            <telerik:RadTreeView ID="RadTreeView1" EnableEmbeddedSkins="false" DataSourceID="XmlDataSource1"
             runat="server" Skin="IV"  OnClientNodeClicked="ClientNodeClicked"  DataNavigateUrlField="ImageUrl" >
             <DataBindings>
                    <telerik:RadTreeNodeBinding SelectedImageUrl="Img/selected_arrow.png" ExpandMode="ClientSide" DataMember="Node" TextField="Text" ExpandedField="Expanded" />
                </DataBindings>
            </telerik:RadTreeView>
              
             
      
            <asp:XmlDataSource runat="server" ID="XmlDataSource1" DataFile="TreeView.xml" XPath="/Tree/Node" />
            <%--<telerik:RadSiteMapDataSource ID="RadSiteMapDataSource1" SiteMapFile="Web.sitemap" runat="server"/>--%>
        </form>
    </body>
    code in .xml file
    <?xml version="1.0" encoding="utf-8" ?>
    <Tree>
      <Node Text="Media Center" ImageUrl="" Expanded="False">
        <Node Text="Press Release" ImageUrl="">
          <Node Text="AppData" ImageUrl="">
            <Node Text="Default" ImageUrl="Default.aspx"/>
          </Node>
          <Node Text="Contacts"  ImageUrl=""/>
          <Node Text="Downloads"  ImageUrl="" />
          <Node Text="Documents" ImageUrl=""/>
          <Node Text="Press Coverage" ImageUrl="" >
            <Node Text="Archives"  ImageUrl="" />
          </Node>
          <Node Text="Music" ImageUrl="" />
          <Node Text="Pictures" ImageUrl="" />
          <Node Text="Saved Games" ImageUrl="" />
          <Node Text="Videos" ImageUrl=""/>
        </Node>
        <Node Text="Press Coverage" ImageUrl="" >
          <Node Text="Archives"  ImageUrl=""/>
        </Node>
        <Node Text="Speaches and Writings" ImageUrl="" >
          <Node Text="Archives"  ImageUrl=""/>
        </Node>
      </Node>
      <Node Text="Default" ImageUrl="Default.aspx" >
        <Node Text="Archives"  ImageUrl=""/>
      </Node>
    </Tree>

    thanks in advance
  • i can able to select the current node by url and one more thing is i cant able to expand the parent node, help me to close this
  • Hi Arunkumar,

    To select a node use set_selected method on the client. get_parent will give you the parent node and set_expanded Expands or collapses a Node.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  • sorry to disturb u again,
    i cant able to expand the parent node on page load event..
    pls try to kick me out from this thread
  • 225847_treeviewimg.png
    its not working for me.
    finaly i got the result, refer the image.
    need to deleselect the remaining child nodes and the parent node be in expanded mode