Select RadTree Item in radComboBox by JavaScript

3 posts, 1 answers
  1. kia
    kia avatar
    17 posts
    Member since:
    Oct 2010

    Posted 05 Mar 2014 Link to this post

    I have a RadComboBox with a radTree in it.
    I have get text and value of tree node from DataBase. Now i want to select item of radTree that equal to value by JavaScript.
    How can i do it?

    Here is definition of RadComboBox:

    <telerik:RadComboBox runat="server" ID="cmb" EnableVirtualScrolling="true"
        Height="140px" ShowToggleImage="True" Style="vertical-align: middle;" Width="100%"
            <telerik:RadTreeView ID="tv" runat="server" OnClientNodeClicking="tv_ClientNodeClicking">
            <telerik:RadComboBoxItem Text="" />
  2. Answer
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 05 Mar 2014 in reply to kia Link to this post

    Hi kia,

    Please try the following JavaScript to access the RadTreeView inside the RadComboBox.

    var Combo = $find("<%=cmb.ClientID %>");//acceessing combobox clientside object
    var Tree = $telerik.findControl(Combo.get_element().parentNode, "tv");//accessing treeview clientside object
    alert(Tree.findNodeByValue("1").get_text());//find a node by value

  3. kia
    kia avatar
    17 posts
    Member since:
    Oct 2010

    Posted 06 Mar 2014 in reply to Shinu Link to this post

    Thank you for your reply.
    I find tvNode by your code and finally select it.
    Here is complete code:
    var Combo = $find("<%=cmb.ClientID %>");
    var Tree = $telerik.findControl(Combo.get_element().parentNode, "tv");
    var tvNode = Tree.findNodeByValue(Value);;
    var parent = tvNode.get_parent();
    if (parent != null)
Back to Top