TreeView in ComboBox

14 posts, 0 answers
  1. FreshOne
    FreshOne avatar
    22 posts
    Member since:
    Jan 2010

    Posted 14 Feb 2010 Link to this post

    hi all,
    i have a grid, which the EditFormType is set to WebUserControl. On edit i need a combobox that contains a treeview, so i followed this example http://demos.telerik.com/aspnet-ajax/treeview/examples/functionality/treeviewcombobox/defaultcs.aspx?product=treeview

    the problem is that when i select a node from the combobox it doesn't respond at the first time, i need to re-select a node again
    here is my code
    <%@ Control Language="vb" AutoEventWireup="false" CodeBehind="Edit.ascx.vb" Inherits="UCMS.LinksEdit" %>  
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>  
     
    <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">  
        <script type="text/javascript">  
            function OpenFileExplorerDialog()  
            {  
                var wnd = $find("<%= ExplorerWindow.ClientID %>");  
                wnd.show();  
            }  
     
            //This function is called from the Explorer.aspx page  
            function OnFileSelected(wnd, fileSelected)  
            {  
                var textbox = $get("<%= fileName.ClientID %>");  
                textbox.value = fileSelected;  
            }     
              
            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_value(node.get_text());  
                comboBox.commitChanges();  
     
                comboBox.hideDropDown();  
            }  
     
            function StopPropagation(e)  
            {  
                if(!e)  
                {  
                    e = window.event;  
                }  
     
                e.cancelBubble = true;  
            }  
              
            function OnClientDropDownOpenedHandler(sender, eventArgs)  
            {  
                var tree = sender.get_items().getItem(0).findControl("RadTreeView1");  
                var selectedNode = tree.get_selectedNode();  
                if (selectedNode)  
                {  
                    selectedNode.scrollIntoView();  
                }  
            }  
        </script>  
    </telerik:RadScriptBlock>  
     
    <telerik:RadWindow runat="server" Width="550px" Height="560px" VisibleStatusbar="false" 
        NavigateUrl="/Components/Links/Explorer.aspx" ID="ExplorerWindow" Modal="true" Behaviors="Close,Move">  
    </telerik:RadWindow>  
     
    <telerik:RadFormDecorator ID="FormDecorator1" runat="server" DecoratedControls="all" Skin="Default"></telerik:RadFormDecorator>  
     
    <br />  
    <table cellpadding="3" cellspacing="0" border="0" width="100%">  
        <tr>  
            <td width="12%">Title:</td>  
            <td width="88%">  
                <telerik:RadTextBox ID="txtTitle" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.title") %>'></telerik:RadTextBox>  
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="txtTitle" ErrorMessage="*" runat="server" Display="Dynamic"></asp:RequiredFieldValidator>  
                <asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="This title is already used" ControlToValidate="txtTitle" Display="Dynamic" OnServerValidate="checkTitle"></asp:CustomValidator>          
            </td>  
        </tr>  
        <tr>  
            <td>Link to:</td>  
            <td>  
                <telerik:RadComboBox ID="RadComboBox2" runat="server" MarkFirstMatch="true" AutoPostBack="true">  
                    <Items>  
                        <telerik:RadComboBoxItem Text="Select type" Value="0" />  
                        <telerik:RadComboBoxItem Text="Page on the website" Value="1" />  
                        <telerik:RadComboBoxItem Text="File on the website" Value="2" />  
                        <telerik:RadComboBoxItem Text="External URL" Value="3" />  
                    </Items>  
                </telerik:RadComboBox>  
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" ControlToValidate="RadComboBox2" ErrorMessage="*" runat="server" Display="Dynamic" InitialValue="Select type"></asp:RequiredFieldValidator>  
            </td>  
        </tr>  
        <tr id="trPages" runat="server" visible="true">  
            <td>Destination:</td>  
            <td>  
                <div>  
                    <telerik:RadComboBox ID="RadComboBox1" runat="server" Height="140px" Width="215px" 
                        ShowToggleImage="True" Style="vertical-align: middle;" OnClientDropDownOpened="OnClientDropDownOpenedHandler" 
                        EmptyMessage="Choose a destination" ExpandAnimation-Type="None" CollapseAnimation-Type="None">  
                        <ItemTemplate>  
                            <div id="div1">  
                                <telerik:RadTreeView runat="server" ID="RadTreeView1" OnClientNodeClicking="nodeClicking" Height="138px" Width="212px">  
                                    <Nodes>  
                                        <telerik:RadTreeNode runat="server" Text="Africa" Expanded="true">  
                                            <Nodes>  
                                                <telerik:RadTreeNode runat="server" Text="Egypt">  
                                                    <Nodes>  
                                                        <telerik:RadTreeNode runat="server" Text="Cairo">  
                                                        </telerik:RadTreeNode>  
                                                    </Nodes>  
                                                </telerik:RadTreeNode>  
                                                <telerik:RadTreeNode runat="server" Text="South Africa">  
                                                    <Nodes>  
                                                        <telerik:RadTreeNode runat="server" Text="Cape Town">  
                                                        </telerik:RadTreeNode>  
                                                    </Nodes>  
                                                </telerik:RadTreeNode>  
                                                <telerik:RadTreeNode runat="server" Text="Kenya">  
                                                    <Nodes>  
                                                        <telerik:RadTreeNode runat="server" Text="Nairobi" Value="1999">  
                                                        </telerik:RadTreeNode>  
                                                    </Nodes>  
                                                </telerik:RadTreeNode>  
                                            </Nodes>  
                                        </telerik:RadTreeNode>  
                                        <telerik:RadTreeNode runat="server" Text="North America" Expanded="true">  
                                            <Nodes>  
                                                <telerik:RadTreeNode runat="server" Text="USA">  
                                                    <Nodes>  
                                                        <telerik:RadTreeNode runat="server" Text="New York">  
                                                        </telerik:RadTreeNode>  
                                                        <telerik:RadTreeNode runat="server" Text="Los Angeles">  
                                                        </telerik:RadTreeNode>  
                                                        <telerik:RadTreeNode runat="server" Text="Boston">  
                                                        </telerik:RadTreeNode>  
                                                    </Nodes>  
                                                </telerik:RadTreeNode>  
                                                <telerik:RadTreeNode runat="server" Text="Canada">  
                                                    <Nodes>  
                                                        <telerik:RadTreeNode runat="server" Text="Toronto">  
                                                        </telerik:RadTreeNode>  
                                                        <telerik:RadTreeNode runat="server" Text="Ottawa">  
                                                        </telerik:RadTreeNode>  
                                                        <telerik:RadTreeNode runat="server" Text="Vancouver">  
                                                        </telerik:RadTreeNode>  
                                                    </Nodes>  
                                                </telerik:RadTreeNode>  
                                                <telerik:RadTreeNode runat="server" Text="Mexico">  
                                                    <Nodes>  
                                                        <telerik:RadTreeNode runat="server" Text="Mexico City">  
                                                        </telerik:RadTreeNode>  
                                                        <telerik:RadTreeNode runat="server" Text="Cancun">  
                                                        </telerik:RadTreeNode>  
                                                    </Nodes>  
                                                </telerik:RadTreeNode>  
                                            </Nodes>  
                                        </telerik:RadTreeNode>  
                                    </Nodes>  
                                </telerik:RadTreeView>  
                            </div>  
                        </ItemTemplate>  
                        <Items>  
                            <telerik:RadComboBoxItem Text="" />  
                        </Items>  
                    </telerik:RadComboBox>  
     
                    <script type="text/javascript">  
                        var div1 = document.getElementById("div1");  
                        div1.onclick = StopPropagation;  
                    </script>  
     
                    <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator3" ErrorMessage="Choose a destination first" ControlToValidate="RadComboBox1" />  
                </div>  
            </td>  
        </tr>  
        <tr id="trFiles" runat="server" visible="false">  
            <td></td>  
            <td>  
                <asp:TextBox ID="fileName" runat="server" Width="350px"></asp:TextBox>  
                <asp:Button ID="selectFile" OnClientClick="OpenFileExplorerDialog(); return false;" Text="Browse" runat="server" />  
            </td>  
        </tr>  
        <tr id="trURL" runat="server" visible="false">  
            <td></td>  
            <td>  
                <telerik:RadTextBox ID="txtURL" runat="server" Width="350px" Text="http://"></telerik:RadTextBox>  
            </td>  
        </tr>          
        <tr>  
            <td>Start Date:</td>  
            <td>  
                <telerik:RadDatePicker ID="RadDatePicker1" runat="server" ></telerik:RadDatePicker>  
                <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToValidate="RadDatePicker1" ErrorMessage="Date can't be earlier than today" Operator="GreaterThanEqual" Type="Date" ValueToCompare='<%# DateTime.Now.ToShortDateString() %>' Display="Dynamic"></asp:CompareValidator>  
            </td>  
        </tr>  
        <tr>  
            <td>End Date:</td>  
            <td>  
                <telerik:RadDatePicker ID="RadDatePicker2" runat="server"></telerik:RadDatePicker>  
                <asp:CompareValidator ID="CompareValidator2" runat="server" ControlToValidate="RadDatePicker2" ErrorMessage="End date can't be earlier than today or earlier than start date" Operator="GreaterThanEqual" Type="Date" ValueToCompare='<%# DateTime.Now.ToShortDateString() %>' ControlToCompare="RadDatePicker1" Display="Dynamic"></asp:CompareValidator>  
            </td>  
        </tr>  
        <tr>  
            <td>Publish:</td>  
            <td>  
                <asp:CheckBox ID="CheckBox1" runat="server"  />  
            </td>  
        </tr>  
        <tr>  
            <td>Category:</td>  
            <td>  
                <telerik:RadComboBox ID="RadComboBox3" runat="server" MarkFirstMatch="true" OnLoad="RadComboBox3_Load" DataTextField="categoryName" DataValueField="categoryID" SelectedValue='<%# DataBinder.Eval(Container, "DataItem.categoryID") %>' AppendDataBoundItems="true"></telerik:RadComboBox>  
                <asp:RequiredFieldValidator ID="RequiredFieldValidator6" ControlToValidate="RadComboBox3" ErrorMessage="*" runat="server" Display="Dynamic" InitialValue="Select category"></asp:RequiredFieldValidator>  
            </td>  
        </tr>  
        <tr>  
            <td align="right" colspan="2">  
                <asp:ImageButton ID="btnUpdate" runat="server" CommandName="Update" Visible='<%# Not (TypeOf DataItem Is Telerik.Web.UI.GridInsertionObject) %>' ImageUrl="/Themes/images/Update.gif" />  
                <asp:ImageButton ID="btnInsert" runat="server" CommandName="PerformInsert" Visible='<%# (TypeOf DataItem Is Telerik.Web.UI.GridInsertionObject) %>' ImageUrl="/Themes/images/Update.gif" />  
                <asp:ImageButton ID="btnCancel" runat="server" CommandName="Cancel" CausesValidation="false" ImageUrl="/Themes/images/Cancel.gif" />  
            </td>  
        </tr>                              
    </table> 

    wht would be causing it??
    any hint is really appreciated
  2. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 17 Feb 2010 Link to this post

    Hi FreshOne,

    I inspected your code but did'n find anything disturbing. Could you please attach the full code so I can see it in details.

    Greetings,
    Veronica Milcheva
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. FreshOne
    FreshOne avatar
    22 posts
    Member since:
    Jan 2010

    Posted 18 Feb 2010 Link to this post

    hi Veronica, thnx for ur reply, here is my code

    <%@ Control Language="vb" AutoEventWireup="false" CodeBehind="view.ascx.vb" Inherits="UCMS.LinksView" %> 
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
     
    <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">  
        <script type="text/javascript">  
            function RowDblClick(sender, eventArgs) {  
                sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());  
            }        
        </script> 
    </telerik:RadScriptBlock> 
     
    <telerik:RadGrid AllowFilteringByColumn="true" AllowSorting="true" ID="RadGrid1" GridLines="None" runat="server"   
            AllowAutomaticDeletes="True" AllowAutomaticInserts="True" PageSize="10" AllowAutomaticUpdates="True" AllowPaging="True" 
            AutoGenerateColumns="False" Skin="Umniah" EnableEmbeddedSkins="false">  
        <PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="true" /> 
        <GroupingSettings CaseSensitive="false" /> 
        <MasterTableView CommandItemDisplay="TopAndBottom" DataKeyNames="linkID" HorizontalAlign="NotSet" AutoGenerateColumns="False" EditMode="PopUp">  
            <Columns> 
                <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn" > 
                </telerik:GridEditCommandColumn> 
                  
               <telerik:GridTemplateColumn HeaderText="Title" SortExpression="title" UniqueName="title" AutoPostBackOnFilter="true" DataField="title">  
                    <ItemTemplate> 
                        <%# Eval("title")%> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn>    
                  
               <telerik:GridTemplateColumn HeaderText="Link" SortExpression="link" UniqueName="link" AutoPostBackOnFilter="true" DataField="link" EditFormColumnIndex="1">  
                    <ItemTemplate> 
                        <href='<%# Eval("link") %>' target="_blank"><%#Eval("link")%></a>  
                    </ItemTemplate> 
                </telerik:GridTemplateColumn>                
                  
                <telerik:GridDateTimeColumn HeaderText="Start Date" SortExpression="startDate" UniqueName="startDate" AutoPostBackOnFilter="true" DataField="startDate" 
                    FilterControlWidth="110px" PickerType="DatePicker" DataFormatString="{0:d/M/yyyy}" ReadOnly="true">  
                </telerik:GridDateTimeColumn>              
     
                <telerik:GridDateTimeColumn HeaderText="End Date" SortExpression="endDate" UniqueName="endDate" AutoPostBackOnFilter="true" DataField="endDate" 
                    FilterControlWidth="110px" PickerType="DatePicker" DataFormatString="{0:d/M/yyyy}" ReadOnly="true">  
                </telerik:GridDateTimeColumn> 
                  
                <telerik:GridCheckBoxColumn HeaderText="Publish" SortExpression="publish" UniqueName="publish" ReadOnly="true" AutoPostBackOnFilter="true" DataField="publish">  
                </telerik:GridCheckBoxColumn>             
                  
                <telerik:GridNumericColumn HeaderText="Visits #" SortExpression="visitsNO" UniqueName="visitsNO" AutoPostBackOnFilter="true" DataField="visitsNO" ReadOnly="true" FilterControlWidth="50px">  
                </telerik:GridNumericColumn> 
                  
                <telerik:GridTemplateColumn HeaderText="Category" SortExpression="categoryName" UniqueName="category" AutoPostBackOnFilter="true" DataField="categoryName">  
                    <ItemTemplate> 
                        <%# Eval("categoryName")%> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn>    
                       
                <telerik:GridButtonColumn ConfirmText="Delete this link?" ConfirmDialogType="RadWindow" ConfirmTitle="Delete Confirmation" 
                    ButtonType="ImageButton" CommandName="Delete" Text="Delete" UniqueName="DeleteColumn">  
                </telerik:GridButtonColumn> 
            </Columns> 
               
            <EditFormSettings CaptionFormatString="Edit Link" PopUpSettings-Modal="true" InsertCaption="Add Link" EditFormType="WebUserControl" UserControlName="Components/Links/Edit.ascx">  
                <FormCaptionStyle CssClass="hide" /> 
                <FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="3" Width="100%" Height="100%" /> 
                <FormTableButtonRowStyle HorizontalAlign="Right" /> 
                <PopUpSettings Width="740px" Height="370px" /> 
                <EditColumn ButtonType="ImageButton" InsertText="Insert link" UpdateText="Update link" 
                    UniqueName="EditCommandColumn1" CancelText="Cancel edit" /> 
            </EditFormSettings> 
        </MasterTableView> 
        <ClientSettings> 
            <ClientEvents OnRowDblClick="RowDblClick" /> 
        </ClientSettings> 
    </telerik:RadGrid> 
     

    Imports Telerik.Web.UI  
     
    Partial Public Class LinksView  
        Inherits System.Web.UI.UserControl  
     
        Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.Load  
            If Not IsPostBack Then 
                RadGrid1.DataSource = bindData()  
                RadGrid1.DataBind()  
            End If 
        End Sub 
     
        Function bindData() As DataTable  
            Dim dt As New DataTable  
            dt.Columns.Add(New DataColumn("linkID"))  
            dt.Columns.Add(New DataColumn("title"))  
            dt.Columns.Add(New DataColumn("link"))  
            dt.Columns.Add(New DataColumn("startDate"))  
            dt.Columns.Add(New DataColumn("endDate"))  
            dt.Columns.Add(New DataColumn("publish"))  
            dt.Columns.Add(New DataColumn("visitsNO"))  
            dt.Columns.Add(New DataColumn("categoryID"))  
            dt.Columns.Add(New DataColumn("categoryName"))  
     
            dt.Columns(0).DataType = System.Type.GetType("System.Int32")  
            dt.Columns(1).DataType = System.Type.GetType("System.String")  
            dt.Columns(2).DataType = System.Type.GetType("System.String")  
            dt.Columns(3).DataType = System.Type.GetType("System.DateTime")  
            dt.Columns(4).DataType = System.Type.GetType("System.DateTime")  
            dt.Columns(5).DataType = System.Type.GetType("System.Boolean")  
            dt.Columns(6).DataType = System.Type.GetType("System.Int32")  
            dt.Columns(7).DataType = System.Type.GetType("System.Int32")  
            dt.Columns(8).DataType = System.Type.GetType("System.String")  
     
            Dim dr As DataRow = dt.NewRow  
            dr.Item(0) = 1  
            dr.Item(1) = "qwer fghjgh" 
            dr.Item(2) = "http://www.google.com" 
            dr.Item(3) = "1/6/2010" 
            dr.Item(4) = "1/7/2010" 
            dr.Item(5) = True 
            dr.Item(6) = 34  
            dr.Item(7) = 1  
            dr.Item(8) = "AA" 
            dt.Rows.Add(dr)  
     
            dr = dt.NewRow  
            dr.Item(0) = 2  
            dr.Item(1) = "rtyuu fghjghj" 
            dr.Item(2) = "http://www.google.com" 
            dr.Item(3) = "1/5/2010" 
            dr.Item(4) = "1/9/2010" 
            dr.Item(5) = False 
            dr.Item(6) = 57  
            dr.Item(7) = 2  
            dr.Item(8) = "BB" 
            dt.Rows.Add(dr)  
     
            dr = dt.NewRow  
            dr.Item(0) = 3  
            dr.Item(1) = "sdfg gfj yj" 
            dr.Item(2) = "http://www.google.com" 
            dr.Item(3) = "1/10/2010" 
            dr.Item(4) = "1/12/2010" 
            dr.Item(5) = False 
            dr.Item(6) = 34  
            dr.Item(7) = 3  
            dr.Item(8) = "CC" 
            dt.Rows.Add(dr)  
     
            dr = dt.NewRow  
            dr.Item(0) = 4  
            dr.Item(1) = "sdg hgj jlkj" 
            dr.Item(2) = "http://www.google.com" 
            dr.Item(3) = "1/4/2010" 
            dr.Item(4) = "1/8/2010" 
            dr.Item(5) = True 
            dr.Item(6) = 34  
            dr.Item(7) = 4  
            dr.Item(8) = "DD" 
            dt.Rows.Add(dr)  
     
            Session("dt") = dt  
            Return dt  
        End Function 
     
        Protected Sub RadGrid1_NeedDataSource(ByVal source As ObjectByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource  
            RadGrid1.DataSource = bindData()  
        End Sub 
     
        Private Sub RadGrid1_ItemCommand(ByVal source As ObjectByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand  
            If e.CommandName = "Update" Then 
                If Page.IsValid Then 
                    'update code  
                    e.Item.Edit = False 
                End If 
            ElseIf e.CommandName = "PerformInsert" Then 
                If Page.IsValid Then 
                    'insert code  
                    e.Canceled = True 
                    e.Item.OwnerTableView.IsItemInserted = False 
                    e.Item.OwnerTableView.Rebind()  
                End If 
            ElseIf e.CommandName = "Delete" Then 
                'delete code  
            End If 
        End Sub 
     
        Private Sub RadGrid1_ItemDataBound(ByVal sender As ObjectByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemDataBound  
            If (TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode) Then 
                Dim item As GridEditableItem = CType(e.Item, GridEditableItem)  
                If (item.OwnerTableView.IsItemInserted) Then 
                    Session("editedItemID") = 0  
                Else 
                    Session("editedItemID") = item.GetDataKeyValue("linkID")  
                End If 
            End If 
        End Sub 
     
    End Class 

    <%@ Control Language="vb" AutoEventWireup="false" CodeBehind="Edit.ascx.vb" Inherits="UCMS.LinksEdit" %> 
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
     
    <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">  
        <script type="text/javascript">  
            function OpenFileExplorerDialog()  
            {  
                var wnd = $find("<%= ExplorerWindow.ClientID %>");  
                wnd.show();  
            }  
     
            //This function is called from the Explorer.aspx page  
            function OnFileSelected(wnd, fileSelected)  
            {  
                var textbox = $get("<%= fileName.ClientID %>");  
                textbox.value = fileSelected;  
            }     
              
            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_value(node.get_text());  
                comboBox.commitChanges();  
     
                comboBox.hideDropDown();  
            }  
     
            function StopPropagation(e)  
            {  
                if(!e)  
                {  
                    e = window.event;  
                }  
     
                e.cancelBubble = true;  
            }  
              
            function OnClientDropDownOpenedHandler(sender, eventArgs)  
            {  
                var tree = sender.get_items().getItem(0).findControl("RadTreeView1");  
                var selectedNode = tree.get_selectedNode();  
                if (selectedNode)  
                {  
                    selectedNode.scrollIntoView();  
                }  
            }  
        </script> 
    </telerik:RadScriptBlock> 
     
    <telerik:RadWindow runat="server" Width="550px" Height="560px" VisibleStatusbar="false" 
        NavigateUrl="/Components/Links/Explorer.aspx" ID="ExplorerWindow" Modal="true" Behaviors="Close,Move">  
    </telerik:RadWindow> 
     
    <telerik:RadFormDecorator ID="FormDecorator1" runat="server" DecoratedControls="all" Skin="Default"></telerik:RadFormDecorator> 
     
    <br /> 
    <table cellpadding="3" cellspacing="0" border="0" width="100%">  
        <tr> 
            <td width="12%">Title:</td> 
            <td width="88%">  
                <telerik:RadTextBox ID="txtTitle" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.title") %>'></telerik:RadTextBox> 
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="txtTitle" ErrorMessage="*" runat="server" Display="Dynamic"></asp:RequiredFieldValidator> 
                <asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="This title is already used" ControlToValidate="txtTitle" Display="Dynamic" OnServerValidate="checkTitle"></asp:CustomValidator>          
            </td> 
        </tr> 
        <tr> 
            <td>Link to:</td> 
            <td> 
                <telerik:RadComboBox ID="RadComboBox2" runat="server" MarkFirstMatch="true" AutoPostBack="true">  
                    <Items> 
                        <telerik:RadComboBoxItem Text="Select type" Value="0" /> 
                        <telerik:RadComboBoxItem Text="Page on the website" Value="1" /> 
                        <telerik:RadComboBoxItem Text="File on the website" Value="2" /> 
                        <telerik:RadComboBoxItem Text="External URL" Value="3" /> 
                    </Items> 
                </telerik:RadComboBox> 
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" ControlToValidate="RadComboBox2" ErrorMessage="*" runat="server" Display="Dynamic" InitialValue="Select type"></asp:RequiredFieldValidator> 
            </td> 
        </tr> 
        <tr id="trPages" runat="server" visible="true">  
            <td>Destination:</td> 
            <td> 
                <div> 
                    <telerik:RadComboBox ID="RadComboBox1" runat="server" Height="140px" Width="215px" 
                        ShowToggleImage="True" Style="vertical-align: middle;" OnClientDropDownOpened="OnClientDropDownOpenedHandler" 
                        EmptyMessage="Choose a destination" ExpandAnimation-Type="None" CollapseAnimation-Type="None">  
                        <ItemTemplate> 
                            <div id="div1">  
                                <telerik:RadTreeView runat="server" ID="RadTreeView1" OnClientNodeClicking="nodeClicking" Height="138px" Width="212px">  
                                    <Nodes> 
                                        <telerik:RadTreeNode runat="server" Text="Africa" Expanded="true">  
                                            <Nodes> 
                                                <telerik:RadTreeNode runat="server" Text="Egypt">  
                                                    <Nodes> 
                                                        <telerik:RadTreeNode runat="server" Text="Cairo">  
                                                        </telerik:RadTreeNode> 
                                                    </Nodes> 
                                                </telerik:RadTreeNode> 
                                                <telerik:RadTreeNode runat="server" Text="South Africa">  
                                                    <Nodes> 
                                                        <telerik:RadTreeNode runat="server" Text="Cape Town">  
                                                        </telerik:RadTreeNode> 
                                                    </Nodes> 
                                                </telerik:RadTreeNode> 
                                                <telerik:RadTreeNode runat="server" Text="Kenya">  
                                                    <Nodes> 
                                                        <telerik:RadTreeNode runat="server" Text="Nairobi" Value="1999">  
                                                        </telerik:RadTreeNode> 
                                                    </Nodes> 
                                                </telerik:RadTreeNode> 
                                            </Nodes> 
                                        </telerik:RadTreeNode> 
                                        <telerik:RadTreeNode runat="server" Text="North America" Expanded="true">  
                                            <Nodes> 
                                                <telerik:RadTreeNode runat="server" Text="USA">  
                                                    <Nodes> 
                                                        <telerik:RadTreeNode runat="server" Text="New York">  
                                                        </telerik:RadTreeNode> 
                                                        <telerik:RadTreeNode runat="server" Text="Los Angeles">  
                                                        </telerik:RadTreeNode> 
                                                        <telerik:RadTreeNode runat="server" Text="Boston">  
                                                        </telerik:RadTreeNode> 
                                                    </Nodes> 
                                                </telerik:RadTreeNode> 
                                                <telerik:RadTreeNode runat="server" Text="Canada">  
                                                    <Nodes> 
                                                        <telerik:RadTreeNode runat="server" Text="Toronto">  
                                                        </telerik:RadTreeNode> 
                                                        <telerik:RadTreeNode runat="server" Text="Ottawa">  
                                                        </telerik:RadTreeNode> 
                                                        <telerik:RadTreeNode runat="server" Text="Vancouver">  
                                                        </telerik:RadTreeNode> 
                                                    </Nodes> 
                                                </telerik:RadTreeNode> 
                                                <telerik:RadTreeNode runat="server" Text="Mexico">  
                                                    <Nodes> 
                                                        <telerik:RadTreeNode runat="server" Text="Mexico City">  
                                                        </telerik:RadTreeNode> 
                                                        <telerik:RadTreeNode runat="server" Text="Cancun">  
                                                        </telerik:RadTreeNode> 
                                                    </Nodes> 
                                                </telerik:RadTreeNode> 
                                            </Nodes> 
                                        </telerik:RadTreeNode> 
                                    </Nodes> 
                                </telerik:RadTreeView> 
                            </div> 
                        </ItemTemplate> 
                        <Items> 
                            <telerik:RadComboBoxItem Text="" /> 
                        </Items> 
                    </telerik:RadComboBox> 
     
                    <script type="text/javascript">  
                        var div1 = document.getElementById("div1");  
                        div1.onclick = StopPropagation;  
                    </script> 
     
                    <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator3" ErrorMessage="Choose a destination first" ControlToValidate="RadComboBox1" /> 
                </div> 
            </td> 
        </tr> 
        <tr id="trFiles" runat="server" visible="false">  
            <td></td>  
            <td> 
                <asp:TextBox ID="fileName" runat="server" Width="350px"></asp:TextBox> 
                <asp:Button ID="selectFile" OnClientClick="OpenFileExplorerDialog(); return false;" Text="Browse" runat="server" /> 
            </td> 
        </tr> 
        <tr id="trURL" runat="server" visible="false">  
            <td></td>  
            <td> 
                <telerik:RadTextBox ID="txtURL" runat="server" Width="350px" Text="http://"></telerik:RadTextBox> 
            </td> 
        </tr>          
        <tr> 
            <td>Start Date:</td> 
            <td> 
                <telerik:RadDatePicker ID="RadDatePicker1" runat="server" ></telerik:RadDatePicker> 
                <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToValidate="RadDatePicker1" ErrorMessage="Date can't be earlier than today" Operator="GreaterThanEqual" Type="Date" ValueToCompare='<%# DateTime.Now.ToShortDateString() %>' Display="Dynamic"></asp:CompareValidator> 
            </td> 
        </tr> 
        <tr> 
            <td>End Date:</td> 
            <td> 
                <telerik:RadDatePicker ID="RadDatePicker2" runat="server"></telerik:RadDatePicker> 
                <asp:CompareValidator ID="CompareValidator2" runat="server" ControlToValidate="RadDatePicker2" ErrorMessage="End date can't be earlier than today or earlier than start date" Operator="GreaterThanEqual" Type="Date" ValueToCompare='<%# DateTime.Now.ToShortDateString() %>' ControlToCompare="RadDatePicker1" Display="Dynamic"></asp:CompareValidator> 
            </td> 
        </tr> 
        <tr> 
            <td>Publish:</td> 
            <td> 
                <asp:CheckBox ID="CheckBox1" runat="server"  /> 
            </td> 
        </tr> 
        <tr> 
            <td>Category:</td> 
            <td> 
                <telerik:RadComboBox ID="RadComboBox3" runat="server" MarkFirstMatch="true" OnLoad="RadComboBox3_Load" DataTextField="categoryName" DataValueField="categoryID" SelectedValue='<%# DataBinder.Eval(Container, "DataItem.categoryID") %>' AppendDataBoundItems="true"></telerik:RadComboBox> 
                <asp:RequiredFieldValidator ID="RequiredFieldValidator6" ControlToValidate="RadComboBox3" ErrorMessage="*" runat="server" Display="Dynamic" InitialValue="Select category"></asp:RequiredFieldValidator> 
            </td> 
        </tr> 
        <tr> 
            <td align="right" colspan="2">  
                <asp:ImageButton ID="btnUpdate" runat="server" CommandName="Update" Visible='<%# Not (TypeOf DataItem Is Telerik.Web.UI.GridInsertionObject) %>' ImageUrl="/Themes/images/Update.gif" /> 
                <asp:ImageButton ID="btnInsert" runat="server" CommandName="PerformInsert" Visible='<%# (TypeOf DataItem Is Telerik.Web.UI.GridInsertionObject) %>' ImageUrl="/Themes/images/Update.gif" /> 
                <asp:ImageButton ID="btnCancel" runat="server" CommandName="Cancel" CausesValidation="false" ImageUrl="/Themes/images/Cancel.gif" /> 
            </td> 
        </tr>                              
    </table> 

     
    Imports Telerik.Web.UI  
    Imports System  
    Imports System.Data  
    Imports System.Configuration  
    Imports System.Collections  
    Imports System.Web  
    Imports System.Web.Security  
    Imports System.Web.UI  
    Imports System.Web.UI.WebControls  
    Imports System.Web.UI.WebControls.WebParts  
    Imports System.Web.UI.HtmlControls  
     
    Partial Public Class LinksEdit  
        Inherits System.Web.UI.UserControl  
     
        Private _dataItem As Object = Nothing 
     
        Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.Load  
            If Not Page.IsPostBack Then 
     
            End If 
        End Sub
    #Region "Web Form Designer generated code"  
     
        Protected Overrides Sub OnInit(ByVal e As EventArgs)  
            '  
            ' CODEGEN: This call is required by the ASP.NET Web Form Designer.  
            '  
            InitializeComponent()  
            MyBase.OnInit(e)  
        End Sub 'OnInit  
     
     
        '/ <summary>  
        '/      Required method for Designer support - do not modify  
        '/      the contents of this method with the code editor.  
        '/ </summary>  
        Private Sub InitializeComponent()  
            AddHandler DataBinding, AddressOf Me.Details_DataBinding  
        End Sub 'InitializeComponent  
     
    #End Region  
     
        Protected Sub Details_DataBinding(ByVal sender As ObjectByVal e As System.EventArgs)  
            If Not DataBinder.Eval(DataItem, "startDate").Equals(DBNull.Value) Then 
                RadDatePicker1.SelectedDate = DataBinder.Eval(DataItem, "startDate")  
            End If 
     
            If Not DataBinder.Eval(DataItem, "endDate").Equals(DBNull.Value) Then 
                RadDatePicker2.SelectedDate = DataBinder.Eval(DataItem, "endDate")  
            End If 
     
            If Not DataBinder.Eval(DataItem, "publish").Equals(DBNull.Value) Then 
                CheckBox1.Checked = DataBinder.Eval(DataItem, "publish")  
            End If 
        End Sub 
     
        Public Property DataItem() As Object 
            Get 
                Return Me._dataItem  
            End Get 
            Set(ByVal value As Object)  
                Me._dataItem = value  
            End Set 
        End Property 
     
        Protected Sub checkTitle(ByVal [source] As ObjectByVal args As System.Web.UI.WebControls.ServerValidateEventArgs)  
            Dim dt As DataTable = CType(Session("dt"), DataTable)  
     
            For i As Integer = 0 To dt.Rows.Count - 1  
                If String.Compare(args.Value, dt.Rows(i).Item("title"), True) = 0 Then 
                    If (Session("editedItemID") = 0) Or (Not Session("editedItemID") = dt.Rows(i).Item("linkID")) Then 
                        args.IsValid = False 
                        Exit For 
                    Else 
                        args.IsValid = True 
                    End If 
                End If 
            Next 
        End Sub 
     
        Protected Sub RadComboBox3_Load(ByVal sender As ObjectByVal e As System.EventArgs)  
            Dim dt As New DataTable  
            dt.Columns.Add(New DataColumn("categoryID"))  
            dt.Columns.Add(New DataColumn("categoryName"))  
     
            dt.Columns(0).DataType = System.Type.GetType("System.Int32")  
            dt.Columns(1).DataType = System.Type.GetType("System.String")  
     
            Dim dr As DataRow = dt.NewRow  
            dr.Item(0) = 1  
            dr.Item(1) = "AA" 
            dt.Rows.Add(dr)  
     
            dr = dt.NewRow  
            dr.Item(0) = 2  
            dr.Item(1) = "BB" 
            dt.Rows.Add(dr)  
     
            dr = dt.NewRow  
            dr.Item(0) = 3  
            dr.Item(1) = "CC" 
            dt.Rows.Add(dr)  
     
            dr = dt.NewRow  
            dr.Item(0) = 4  
            dr.Item(1) = "DD" 
            dt.Rows.Add(dr)  
     
            RadComboBox3.DataSource = dt  
     
            Dim baseItem As New RadComboBoxItem  
            baseItem.Text = "Select category" 
            baseItem.Value = "0" 
            RadComboBox3.Items.Add(baseItem)  
        End Sub 
     
        Private Sub RadComboBox2_SelectedIndexChanged(ByVal o As ObjectByVal e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs) Handles RadComboBox2.SelectedIndexChanged  
            Select Case e.Value  
                'Case 0  
                '    trPages.Visible = False  
                '    trFiles.Visible = False  
                '    trURL.Visible = False  
                Case 1  
                    trPages.Visible = True 
                    trFiles.Visible = False 
                    trURL.Visible = False 
                Case 2  
                    trPages.Visible = False 
                    trFiles.Visible = True 
                    trURL.Visible = False 
                Case 3  
                    trPages.Visible = False 
                    trFiles.Visible = False 
                    trURL.Visible = True 
            End Select 
        End Sub 
     
        'Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)  
        '    Label1.Text = "You selected " + RadComboBox1.Text  
        '    RadComboBox1.Items(0).Text = RadComboBox1.Text  
        'End Sub  
     
    End Class 

    really appreciated
  5. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 24 Feb 2010 Link to this post

    Hello,

    I've attached a vide presentation of what I get when i tried your code. Please could you tell me what Browser do you use to test the project? My video screen capture is made with IE8. I also tested the example with IE7 and Firefox.


    Greetings,
    Veronica Milcheva
    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.
  6. pavan
    pavan avatar
    17 posts
    Member since:
    Aug 2010

    Posted 05 Aug 2010 Link to this post

    Hello,
    I have implemented the same code which is in the telerik demo site (application scenarios->treeview in combo box) .Whenever i am trying to select a treeview item from the combo box i am able to do it for the first time.(I havent included the submit button and the label).If i want to select another element from the tree view from the combobox for the second time the tree view is not at all being displayed.can u suggest a solution for this?
    I am attaching my code. 
  7. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 05 Aug 2010 Link to this post

    Hi pavan,

    Unfortunately I haven't received your code. Can you try to send it again please?

    Thank you!

    Kind regards,
    Veronica Milcheva
    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
  8. pavan
    pavan avatar
    17 posts
    Member since:
    Aug 2010

    Posted 06 Aug 2010 Link to this post

    <%@ Page AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default"
        Language="c#" %>
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Untitled Page</title>
        <meta http-equiv="refresh" content="10" />
    </head>
    <body>

        <form runat="server" id="form1" method="post">
            <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
     
            <telerik:RadFormDecorator ID="FormDecorator1" runat="server" DecoratedControls="all" ControlsToSkip="Scrollbars"></telerik:RadFormDecorator>
            <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 timedRefresh(timeoutPeriod)
    //{
    // setTimeout("location.reload(true);",timeoutPeriod);
    //}

     

                function StopPropagation(e)
                {
                    if(!e)
                    {
                        e = window.event;
                    }

                    e.cancelBubble = true;
                }
               
                function OnClientDropDownOpenedHandler(sender, eventArgs)
                {
                try{
                    var tree = sender.get_items().getItem(0).findControl("RadTreeView1");
                    var selectedNode = tree.get_selectedNode();
                    if (selectedNode)
                    {
                        selectedNode.get_element().scrollIntoView();
                    }
                    }
                    catch(e)
                    {
                   
                    }
                }
         </script>
    <%--//                   <p>
    //<a href="javascript:timedRefresh(2000)"></a>
    //</p> --%>
     Fiscal Period:
                <telerik:RadComboBox ID="RadComboBox1" runat="server" Height="140px" Width="215px"
                    ShowToggleImage="True" Style="vertical-align: middle;" AutoPostBack="true" OnClientDropDownOpened="OnClientDropDownOpenedHandler"
                    EmptyMessage="SELECT FISCAL PERIOD" ExpandAnimation-Type="None" CollapseAnimation-Type="None">
                    <ItemTemplate>
                        <div id="div1">
                            <telerik:RadTreeView runat="server" ID="RadTreeView1"  AutoPostBack="true"
                             OnClientNodeClicking="nodeClicking" Height="138px" Width="212px">
    <Nodes>
                                    <telerik:RadTreeNode runat="server" Text="FY1" Expanded="true">
                                        <Nodes>
                                            <telerik:RadTreeNode runat="server" Text="H1">
                                                <Nodes>
                                                    <telerik:RadTreeNode runat="server" Text="Q1">
                                                    </telerik:RadTreeNode>
                                                    <telerik:RadTreeNode runat="server" Text="Q2">
                                                    </telerik:RadTreeNode>
                                                </Nodes>
                                            </telerik:RadTreeNode>
                                            <telerik:RadTreeNode runat="server" Text="H2">
                                                <Nodes>
                                                    <telerik:RadTreeNode runat="server" Text="Q3">
                                                    </telerik:RadTreeNode>
                                                    <telerik:RadTreeNode runat="server" Text="Q4">
                                                    </telerik:RadTreeNode>
                                                </Nodes>
                                            </telerik:RadTreeNode>
                                         </Nodes>
                                      </telerik:RadTreeNode>
                                </Nodes>
                            </telerik:RadTreeView>
                        </div>
                    </ItemTemplate>
                    <Items>
                        <telerik:RadComboBoxItem Text="" />
                    </Items>
                </telerik:RadComboBox>
     
               <%-- <script type="text/javascript">
                    var div1 = document.getElementById("div1");
                    div1.onclick = StopPropagation;
                </script>--%>
                  </form>
    </body>
    </html>

                                         

     

    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    using System;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;
    using Telerik.Web.UI;

    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
       
    {
        RadTreeView obj_radTimeTree =
                    (RadTreeView)RadComboBox1.Controls[2].FindControl("RadTreeView1");

        obj_radTimeTree.ExpandAllNodes();

        }
      

    }

  9. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 09 Aug 2010 Link to this post

    Hello pavan,

    This is a known issue and it is fixed in Q1 2010 and upper versions.

    Please let me know if upgrading to a newer version is an option for you.

    Best wishes,
    Veronica Milcheva
    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
  10. pavan
    pavan avatar
    17 posts
    Member since:
    Aug 2010

    Posted 09 Aug 2010 Link to this post

    Hello,
    I didn't get what Q1 2010  and upper versions meant in ur reply.
  11. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 09 Aug 2010 Link to this post

    Hello pavan,

    In my previous post I mean that this is a known issue in the 2009.3 1314 which we fixed in Q1 2010 (2010.1.309) and upper versions.

    So, to be able to get this fixed - you'll need to upgrade to a later version.

    Kind regards,
    Veronica Milcheva
    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
  12. pavan
    pavan avatar
    17 posts
    Member since:
    Aug 2010

    Posted 17 Aug 2010 Link to this post

    Hi,
    Actually i am using the same version of dll i.e 2010.1.309 .Even i am getting the same problem.
  13. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 19 Aug 2010 Link to this post

    Hi pavan,

    Please accept my apologies.

    I've tested with version 2010.1.309 but it seems the site was cached and I was not able to see the problem.

    The real version in which the problem is fixed is 2010.1.415:

    Fixed: The client-side RadComboBoxItem.set_text() method clears the content of the ItemTemplate (if any)

    Regards,
    Veronica Milcheva
    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
  14. Rene de Vries
    Rene de Vries avatar
    8 posts
    Member since:
    May 2003

    Posted 06 Oct 2010 Link to this post

    Hi Veronica,

    Is there a workaround if upgrading is not an option at the moment?
  15. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 11 Oct 2010 Link to this post

    Hi Rene de Vries,

    Unfortunately the fix is not that simple. There is no workaround for previous versions.

    Please accept our apologies for the caused inconvenience.

    All the best,
    Veronica MIlcheva
    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017