Radtreeview show more than one in Radcombobox

3 posts, 0 answers
  1. Ahmad
    Ahmad avatar
    2 posts
    Member since:
    Mar 2012

    Posted 14 Sep 2012 Link to this post

    Hi,

    I try to use RadTreeView using data binding and it shows correctly, but why when i'm trying to use RadTreeView on RadComboBox it shows more than one. Here is my aspx code :

    <%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
        CodeBehind="Default.aspx.cs" Inherits="treeOnCombo._Default" %>
     
    <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
    <script type="text/javascript">
        function nodeClicking(sender, args) {
            var comboBox = $find("<%= RadComboBox1.ClientID %>");
     
            var node = args.get_node()
     
            comboBox.set_text(node.get_text());
     
            comboBox.trackChanges();
            comboBox.get_items().getItem(0).set_text(node.get_text());
            comboBox.commitChanges();
     
            comboBox.hideDropDown();
        }
     
        function OnClientDropDownOpenedHandler(sender, eventArgs) {
            var tree = sender.get_items().getItem(0).findControl("RadTreeView1");
            var selectedNode = tree.get_selectedNode();
            if (selectedNode) {
                selectedNode.scrollIntoView();
            }
        }
        </script>
    </asp:Content>
    <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
        <h2>
            Welcome to ASP.NET!
        </h2>
        <p>
            To learn more about ASP.NET visit <a href="http://www.asp.net" title="ASP.NET Website">www.asp.net</a>.
        </p>
        <p>
            You can also find <a href="http://go.microsoft.com/fwlink/?LinkID=152368&;clcid=0x409"
                title="MSDN ASP.NET Docs">documentation on ASP.NET at MSDN</a>.
        </p>
    <br />
    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" height="100%"
        width="99%">
        <table border="1px" style="width:100%;">
            <tr>
                <td>
                     </td>
                <td>
                     </td>
                <td>
                     </td>
            </tr>
            <tr>
                <td>
                    RadTreeView :</td>
                <td>
                    <telerik:RadTreeView ID="RadTreeView1" Runat="server" DataFieldID="ID"
                        DataFieldParentID="PARENT" DataSourceID="SqlDataSource1" DataTextField="MENU"
                        DataValueField="ID">
                    </telerik:RadTreeView>
                </td>
                <td>
                     </td>
            </tr>
            <tr>
                <td>
                    RadTreeView on RadComboBox :</td>
                <td>
                    <telerik:RadComboBox ID="RadComboBox1" Runat="server"
                        DataSourceID="SqlDataSource1" DataTextField="MENU" DataValueField="ID"
                        EmptyMessage="-- Choose One --" Height="200px"
                        OnClientDropDownOpened="OnClientDropDownOpenedHandler">
                        <ItemTemplate>
                            <telerik:RadTreeView ID="RadTreeView1" Runat="server" DataFieldID="ID"
                                DataFieldParentID="PARENT" DataSourceID="SqlDataSource1" DataTextField="MENU"
                                DataValueField="ID" OnClientNodeClicking="nodeClicking">
                            </telerik:RadTreeView>
                        </ItemTemplate>
                    </telerik:RadComboBox>
                </td>
                <td>
                     </td>
            </tr>
        </table>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server"
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
            SelectCommand="SELECT * FROM [MENU]"></asp:SqlDataSource>
    </telerik:RadAjaxPanel>
    </asp:Content>


    Any help would be really appreciated.

    Thanks
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 17 Sep 2012 Link to this post

    Hi Ahmed,

    I too experienced the issue you are facing. One suggestion is that you can use footer template to generate treeview in combobox as follows.

    ASPX:
    <telerik:RadComboBox ID="RadComboBox1" Runat="server"
      DataSourceID="SqlDataSource1" DataTextField="name" DataValueField="id"
      EmptyMessage="-- Choose One --" Height="200px"
      OnClientDropDownOpened="OnClientDropDownOpenedHandler">
     <FooterTemplate>
        <telerik:RadTreeView ID="RadTreeView1" Runat="server" DataFieldID="id"
         DataFieldParentID="parent" DataSourceID="SqlDataSource1" DataTextField="name"
         DataValueField="id" OnClientNodeClicking="nodeClicking">
       </telerik:RadTreeView>
      </FooterTemplate>
    </telerik:RadComboBox>

    Thanks,
    Princy.
  3. Ahmad
    Ahmad avatar
    2 posts
    Member since:
    Mar 2012

    Posted 24 Sep 2012 Link to this post

    Thanks Princy, that's worked for me..
Back to Top