Terry Webster
Top achievements
Rank 2
Terry Webster
asked on 26 Feb 2008, 02:31 PM
I am using the existing example of the RadTreeView in a RadComboBox, but I am trying to do LoadOnDemand. However, I cannot find the RadTreeView control in the RadComboBox items collection.
Any ideas?
Terry Webster
Chief Technology Architect
Highmark Technology
| Private Sub LoadRootNodes() |
| Dim rtvClient As RadTreeView = Nothing |
| For Each myItem As RadComboBoxItem In RadComboBox1.Items |
| rtvClient = DirectCast(myItem.FindControl("rtvClient"), RadTreeView) |
| rtvClient.Nodes.Clear() |
| Exit For |
| Next |
| Dim ta As New dsHospiScriptTableAdapters.spDBList_GetHierarchy_ClientTableAdapter |
| Dim dt As New dsHospiScript.spDBList_GetHierarchy_ClientDataTable |
| ta.Fill(dt, Nothing, -1, Session.Item("HSUserID")) |
| Dim row As DataRow |
| For Each row In dt.Rows |
| Dim node As New RadTreeNode() |
| node.Text = CStr(row("MemberName")) |
| node.Value = CStr(row("MemberId")) |
| Session("Client") = row("MemberId") |
| node.Category = "Some Category" |
| node.ExpandMode = TreeNodeExpandMode.ServerSideCallBack |
| rtvClient.Nodes.Add(node) |
| Next row |
| dt = Nothing |
| ta = Nothing |
| End Sub 'LoadRootNodes |
Any ideas?
Terry Webster
Chief Technology Architect
Highmark Technology
4 Answers, 1 is accepted
0
Terry Webster
Top achievements
Rank 2
answered on 27 Feb 2008, 05:22 PM
Anyone got a clue on how to do this?
0
Hi Terry Webster,
The most probable reason for not finding the RadTreeView is that the ID by which you search for it do not match with the one declared in the aspx. Please, check whether they match correctly:
Regards,
Simon
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
The most probable reason for not finding the RadTreeView is that the ID by which you search for it do not match with the one declared in the aspx. Please, check whether they match correctly:
| <telerik:RadTreeView runat="server" ID="rtvClient" ... > |
| rtvClient = DirectCast(myItem.FindControl("rtvClient"), RadTreeView) |
Regards,
Simon
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
Terry Webster
Top achievements
Rank 2
answered on 28 Feb 2008, 03:52 PM
I had that. What I found out was that I did not have the <items /> section. Once I added that, I was able to find and reference the control. Now the only problem I am having is that the events are not firing correctly on the control. For example, I can expand the ComboBox and then try to click on the first node in the RadTreeView, but nothing happens. Here is a copy of my code for your review.
ASPX:
ASPX:
| <%@ Master Language="VB" CodeFile="MasterPage2.master.vb" Inherits="MasterPage2" %> | |
| <%@ Register Src="DashboardMenu.ascx" TagName="DashboardMenu" TagPrefix="uc13" %> | |
| <%@ Register Src="DashboardLogo.ascx" TagName="DashboardLogo" TagPrefix="uc14" %> | |
| <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> | |
| <!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" style="height: 100%; margin: 0px"> | |
| <head id="Head1" runat="server"> | |
| <title>HospiScript Dashboards</title> | |
| <link href="/Common/StyleSheet.css" rel="stylesheet" type="text/css" /> | |
| <link href="~/Skins/Hospiscript/Calendar.Hospiscript.css" rel="stylesheet" type="text/css" runat="server" /> | |
| <link href="~/Skins/Hospiscript/ComboBox.Hospiscript.css" rel="stylesheet" type="text/css" runat="server" /> | |
| <link href="~/Skins/Hospiscript/Grid.Hospiscript.css" rel="stylesheet" type="text/css" runat="server" /> | |
| <link href="~/Skins/Hospiscript/Menu.Hospiscript.css" rel="stylesheet" type="text/css" runat="server" /> | |
| <link href="~/Skins/Hospiscript/Splitter.Hospiscript.css" rel="stylesheet" type="text/css" runat="server" /> | |
| <link href="~/Skins/Hospiscript/TreeView.Hospiscript.css" rel="stylesheet" type="text/css" runat="server" /> | |
| </head> | |
| <body alink="#7b7984" style="height: 100%; margin: 0px; overflow: hidden;" scroll="no"> | |
| <form id="form1" runat="server" style="height: 100%; margin: 0px"> | |
| <telerik:RadAjaxManager ID="RadAjaxManager2" runat="server"> | |
| <AjaxSettings> | |
| <telerik:AjaxSetting AjaxControlID="Button1"> | |
| <UpdatedControls> | |
| <telerik:AjaxUpdatedControl ControlID="ContentPane" /> | |
| </UpdatedControls> | |
| </telerik:AjaxSetting> | |
| </AjaxSettings> | |
| </telerik:RadAjaxManager> | |
| <telerik:RadSplitter ID="MainSplitter" runat="server" Height="100%" Width="100%" | |
| Skin="Default2006" Orientation="Horizontal" EnableEmbeddedSkins="false"> | |
| <telerik:RadPane ID="TopPane" runat="server" Height="98" MinHeight="94" MaxHeight="94" | |
| Width="100%" Scrolling="none"> | |
| <div style="padding-bottom: 10px; background-color: Aqua;"> | |
| <table cellpadding="0" cellspacing="0" style="width: 100%; background-color: White;"> | |
| <tr> | |
| <td valign="bottom" style="text-align: left;"> | |
| <uc14:DashboardLogo ID="DashboardLogo1" runat="server"></uc14:DashboardLogo> | |
| </td> | |
| <td align="right" valign="bottom" style="margin-bottom: 15px;"> | |
| <uc13:DashboardMenu ID="DashboardMenu1" runat="server"></uc13:DashboardMenu> | |
| </td> | |
| </tr> | |
| </table> | |
| </div> | |
| </telerik:RadPane> | |
| <telerik:RadSplitBar ID="RadsplitbarTop" runat="server" CollapseMode="Forward" EnableResize="false" /> | |
| <telerik:RadPane ID="MainPane" runat="server" Scrolling="none" MinWidth="500" Width="100%"> | |
| <script type="text/javascript"> | |
| function nodeClicking(sender, args) | |
| { | |
| var comboBox = $find('RadComboBox1'); | |
| var node = args.get_node() | |
| comboBox.set_text(node.get_text()); | |
| comboBox.hideDropDown(); | |
| } | |
| function StopPropagation(e) | |
| { | |
| if(!e) | |
| { | |
| e = window.event; | |
| } | |
| e.cancelBubble = true; | |
| } | |
| </script> | |
| <telerik:RadSplitter ID="RadSplitter1" runat="server" Width="100%" BorderColor="#E0E0E0" | |
| BorderStyle="Solid" BorderWidth="2px" Height="80%" Skin="Default2006" EnableEmbeddedSkins="false"> | |
| <telerik:RadPane ID="RadPane1" runat="server" Width="25" Scrolling="None"> | |
| <telerik:RadSlidingZone ID="RadSlidingZone1" runat="server" Width="25"> | |
| <telerik:RadSlidingPane ID="RadSlidingPane1" runat="server" Title=" Filters " | |
| Width="500" BorderStyle="Solid" Scrolling="None" BackColor="whitesmoke"> | |
| <table cellpadding="10" cellspacing="0" style="border: 0px; background-color: whitesmoke;"> | |
| <tr> | |
| <td valign="top" align="right" style="width: 100px"> | |
| <asp:Label ID="Label1" runat="server" Text="Start Date:" EnableViewState="False" | |
| Font-Names="Verdana" Font-Size="Small"></asp:Label> | |
| </td> | |
| <td valign="top" align="left"> | |
| <telerik:RadDatePicker ID="rdpStartDate" runat="server" EnableEmbeddedSkins="False" DateInput-EnableEmbeddedSkins="False"> | |
| </telerik:RadDatePicker> | |
| <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="rdpStartDate" | |
| ErrorMessage="Required" Font-Names="Verdana" Font-Size="Small"></asp:RequiredFieldValidator> | |
| </td> | |
| </tr> | |
| <tr> | |
| <td valign="top" align="right" style="width: 100px"> | |
| <asp:Label ID="Label2" runat="server" Text="End Date:" EnableViewState="False" Font-Names="Verdana" | |
| Font-Size="Small"></asp:Label></td> | |
| <td valign="top" align="left"> | |
| <telerik:RadDatePicker ID="rdpEndDate" runat="server" EnableEmbeddedSkins="False" DateInput-EnableEmbeddedSkins="False"> | |
| </telerik:RadDatePicker> | |
| <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="rdpEndDate" | |
| ErrorMessage="Required" Font-Names="Verdana" Font-Size="Small"></asp:RequiredFieldValidator> | |
| </td> | |
| </tr> | |
| <tr> | |
| <td valign="top" align="right" style="width: 100px"> | |
| <asp:Label ID="Label4" runat="server" Text="Level:" EnableViewState="False" Font-Names="Verdana" | |
| Font-Size="Small"></asp:Label></td> | |
| <td valign="top" align="left"> | |
| <telerik:RadComboBox ID="RadComboBox1" Height="350px" Width="421px" ShowToggleImage="true" | |
| EnableEmbeddedSkins="false" runat="server"> | |
| <ItemTemplate> | |
| <div id="div1" class="DropDownTreeViewDiv"> | |
| <telerik:RadTreeView ID="rtvClient" runat="server" ExpandDelay="0" Height="350px" | |
| Width="421px" LoadingStatusPosition="AfterNodeText" EnableEmbeddedSkins="False" | |
| PersistLoadOnDemandNodes="true"> | |
| </telerik:RadTreeView> | |
| </div> | |
| </ItemTemplate> | |
| <Items> | |
| <telerik:RadComboBoxItem></telerik:RadComboBoxItem> | |
| </Items> | |
| <CollapseAnimation Duration="200" Type="OutQuint" /> | |
| <ExpandAnimation Type="OutQuart" /> | |
| </telerik:RadComboBox> | |
| <script type="text/javascript"> | |
| var div1 = document.getElementById("div1"); | |
| div1.onclick = StopPropagation; | |
| </script> | |
| </td> | |
| </tr> | |
| <tr> | |
| <td style="width: 100px"> | |
| </td> | |
| <td align="left"> | |
| <table border="0" cellpadding="0" cellspacing="0"> | |
| <tr> | |
| <td valign="middle"> | |
| <asp:RadioButtonList ID="rblRxType" runat="server" RepeatDirection="Horizontal" RepeatColumns="2" | |
| EnableViewState="False" Font-Names="Verdana" Font-Size="Small"> | |
| <asp:ListItem Selected="True" Text="Processed" Value="1" /> | |
| <asp:ListItem Selected="False" Text="Filled" Value="2" /> | |
| </asp:RadioButtonList> | |
| <asp:LinkButton ID="LinkButton2" runat="server" EnableViewState="False" Font-Names="Verdana" | |
| Font-Size="Small">What's the difference?</asp:LinkButton> | |
| </td> | |
| </tr> | |
| </table> | |
| </td> | |
| </tr> | |
| <tr> | |
| <td colspan="2" align="right" valign="Top"> | |
| <asp:Button ID="Button1" runat="server" Text="Submit" Font-Names="Verdana" Font-Size="Small" /> | |
| </td> | |
| </tr> | |
| </table> | |
| <asp:HiddenField ID="hidClient" runat="server" /> | |
| </telerik:RadSlidingPane> | |
| </telerik:RadSlidingZone> | |
| </telerik:RadPane> | |
| <telerik:RadSplitBar ID="RadSplitBar1" runat="server" CollapseMode="Forward" EnableResize="false" /> | |
| <telerik:RadPane ID="ContentPane" runat="server" Height="" Width=""> | |
| <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"> | |
| </asp:ContentPlaceHolder> | |
| </telerik:RadPane> | |
| </telerik:RadSplitter> | |
| </telerik:RadPane> | |
| <telerik:RadSplitBar ID="RadsplitbarMain" runat="server" CollapseMode="Backward" | |
| EnableResize="false" /> | |
| <telerik:RadPane ID="BottomPane" runat="server" Height="75" MinHeight="75" MaxHeight="75" | |
| Width="100%" Scrolling="none"> | |
| <table style="width: 100%;" cellpadding="0" cellspacing="0" border="0"> | |
| <tr> | |
| <td style="text-align: left; color: #333333; padding-top: 5px; border-top: solid 4px #E8E8E8; | |
| font: normal normal normal 7pt/normal Arial, San-Serif;"> | |
| <asp:Label ID="lblCopyright" runat="server" Text=""></asp:Label> | |
| </td> | |
| </tr> | |
| <tr> | |
| <td style="text-align: center; color: #996699; font: normal normal normal 8.5pt/normal Arial, San-Serif; | |
| padding: 4px 4px 4px 4px;"> | |
| <asp:Label ID="lblCustomerService" runat="server" Text=""></asp:Label> | <asp:Label | |
| ID="lblPharmacyServices" runat="server" Text=""></asp:Label> | |
| </td> | |
| </tr> | |
| <tr> | |
| <td style="text-align: center; color: #996699; font: normal normal normal 8.5pt/normal Arial, San-Serif; | |
| padding: 4px 4px 4px 4px;"> | |
| <asp:Label ID="lblHospiScriptAddress" runat="server" Text=""></asp:Label> | |
| </td> | |
| </tr> | |
| </table> | |
| </telerik:RadPane> | |
| </telerik:RadSplitter> | |
| <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> | |
| <AjaxSettings> | |
| <telerik:AjaxSetting AjaxControlID="rtvClient"> | |
| <UpdatedControls> | |
| <telerik:AjaxUpdatedControl ControlID="txtClient"></telerik:AjaxUpdatedControl> | |
| <telerik:AjaxUpdatedControl ControlID="rtvClient"></telerik:AjaxUpdatedControl> | |
| </UpdatedControls> | |
| </telerik:AjaxSetting> | |
| </AjaxSettings> | |
| </telerik:RadAjaxManager> | |
| </form> | |
| <script type="text/javascript"> | |
| function PrintPane (paneID) | |
| { | |
| //var splitter = $find("ctl00_RadSplitter1"); | |
| var splitter = $find("ctl00_RadSplitter1"); | |
| var pane = splitter.getPaneById(paneID); | |
| if (!pane) return; | |
| var cssFileAbsPath = location.href.substr(0, location.href.toString().lastIndexOf('/') + 1) + 'Common/StyleSheet.css'; | |
| var cssFileAbsPath1 = location.href.substr(0, location.href.toString().lastIndexOf('/') + 1) + 'RadControls/Grid/Skins/Mac/Styles.css'; | |
| var arrExtStylsheetFiles = [ | |
| cssFileAbsPath, cssFileAbsPath1 | |
| ]; | |
| pane.print(arrExtStylsheetFiles); | |
| } | |
| </script> | |
| </body> | |
| </html> | |
VB:
| Imports System.Data | |
| Imports System.Web.UI.WebControls | |
| Imports Telerik.Web.UI | |
| Partial Class MasterPage2 | |
| Inherits System.Web.UI.MasterPage | |
| Public Sub UpdateParameters(ByVal StartDate As Date, ByVal EndDate As Date, ByVal Client As String, ByVal ClientName As String, ByVal RxType As Integer) | |
| Session("StartDate") = StartDate | |
| Session("EndDate") = EndDate | |
| Session("Client") = Client | |
| Session("ClientName") = ClientName | |
| Session("RxType") = RxType | |
| End Sub | |
| Private Sub LoadRootNodes() | |
| Dim rtvClient As RadTreeView = Nothing | |
| For Each myItem As RadComboBoxItem In RadComboBox1.Items | |
| rtvClient = DirectCast(myItem.FindControl("rtvClient"), RadTreeView) | |
| 'rtvClient.Nodes.Clear() | |
| Exit For | |
| Next | |
| Dim ta As New dsHospiScriptTableAdapters.spDBList_GetHierarchy_ClientTableAdapter | |
| Dim dt As New dsHospiScript.spDBList_GetHierarchy_ClientDataTable | |
| ta.Fill(dt, Nothing, -1, Session.Item("HSUserID")) | |
| Dim row As DataRow | |
| For Each row In dt.Rows | |
| Dim node As New RadTreeNode() | |
| node.Text = CStr(row("MemberName")) | |
| node.Value = CStr(row("MemberId")) | |
| Session("Client") = row("MemberId") | |
| 'node.Category = "Some Category" | |
| node.ExpandMode = TreeNodeExpandMode.ServerSideCallBack | |
| rtvClient.Nodes.Add(node) | |
| Next row | |
| dt = Nothing | |
| ta = Nothing | |
| End Sub 'LoadRootNodes | |
| Protected Function GetClientMemberName(ByVal ClientID As Integer, ByVal ClientLevel As Integer, ByVal UserID As Integer) As String | |
| Dim ta As New dsHospiScriptTableAdapters.spDBList_GetClientPageFilterTableAdapter | |
| Dim dt As New dsHospiScript.spDBList_GetClientPageFilterDataTable | |
| Dim ClientMemberName As String = "" | |
| ta.Fill(dt, ClientID, ClientLevel, UserID) | |
| For Each dr As dsHospiScript.spDBList_GetClientPageFilterRow In dt | |
| ClientMemberName = dr.ClientSlicer | |
| Exit For | |
| Next | |
| Return ClientMemberName | |
| dt = Nothing | |
| ta = Nothing | |
| End Function | |
| Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load | |
| lblCopyright.Text = ConfigurationManager.AppSettings.Item("CopyrightInfo").Replace("%%YEAR%%", Year(Now()).ToString) | |
| lblCustomerService.Text = ConfigurationManager.AppSettings.Item("CustomerServiceInfo") | |
| lblPharmacyServices.Text = ConfigurationManager.AppSettings.Item("PharmacyServicesInfo") | |
| lblHospiScriptAddress.Text = ConfigurationManager.AppSettings.Item("HospiScriptAddressInfo") | |
| If Not Page.IsPostBack Then | |
| Session("StartDate") = "2/1/2007" | |
| Session("EndDate") = "2/28/2007" | |
| Session("Client") = Nothing | |
| Session("ClientLevel") = -1 | |
| Session("ClientName") = "All" | |
| Session("RxType") = "2" | |
| Session("ClientMemberName") = GetClientMemberName(Session("Client"), Session("ClientLevel"), Session("HSUserID")) | |
| End If | |
| Dim rtvClient As RadTreeView = Nothing | |
| For Each myItem As RadComboBoxItem In RadComboBox1.Items | |
| rtvClient = DirectCast(myItem.FindControl("rtvClient"), RadTreeView) | |
| Exit For | |
| Next | |
| If Not Page.IsPostBack Then | |
| LoadRootNodes() | |
| rdpStartDate.SelectedDate = CType(Session("StartDate"), Date) | |
| rdpEndDate.SelectedDate = CType(Session("EndDate"), Date) | |
| rtvClient.Nodes.FindNodeByValue(Session("Client")).Selected = True | |
| rblRxType.SelectedValue = Session("RxType") | |
| Else | |
| Dim rtnSelectedNode As RadTreeNode = Nothing | |
| If Not rtvClient.SelectedNode Is Nothing Then | |
| rtnSelectedNode = rtvClient.SelectedNode | |
| End If | |
| If Not rtvClient.SelectedNode Is Nothing Then | |
| UpdateParameters(rdpStartDate.SelectedDate, rdpEndDate.SelectedDate, rtvClient.SelectedNode.Value, rtvClient.SelectedNode.Text, rblRxType.SelectedValue) | |
| End If | |
| End If | |
| End Sub | |
| Protected Sub rtvClient_NodeExpand(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadTreeNodeEventArgs) ' Handles rtvClient.NodeExpand | |
| Dim ta As New dsHospiScriptTableAdapters.spDBList_GetHierarchy_ClientTableAdapter | |
| Dim dt As New dsHospiScript.spDBList_GetHierarchy_ClientDataTable | |
| Dim ParentID As String = e.Node.Value | |
| ta.Fill(dt, ParentID, e.Node.Level, Session("HSUserID")) | |
| Dim row As DataRow | |
| For Each row In dt.Rows | |
| Dim childNode As New RadTreeNode() | |
| childNode.Text = CStr(row("MemberName")) | |
| childNode.Value = CStr(row("MemberID")) | |
| If CInt(row("LevelID")) < 3 Then | |
| childNode.ExpandMode = TreeNodeExpandMode.ServerSideCallBack | |
| End If | |
| e.Node.Nodes.Add(childNode) | |
| Next row | |
| e.Node.Expanded = True | |
| ParentID = Nothing | |
| dt = Nothing | |
| ta = Nothing | |
| End Sub | |
| End Class | |
0
Hello Terry Webster,
Thank you for getting back to me.
What I observed in your code is that you missed subscribing to the corresponding events of the RadTreeView.
I suggest you add the following attributes to the control declaration: OnNodeExpand="rtvClient_NodeExpand" and OnClientNodeClicking="nodeClicking".
This way the events should fire as expected.
If any further questions arise, please feel free to ask them.
Kind regards,
Simon
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Thank you for getting back to me.
What I observed in your code is that you missed subscribing to the corresponding events of the RadTreeView.
I suggest you add the following attributes to the control declaration: OnNodeExpand="rtvClient_NodeExpand" and OnClientNodeClicking="nodeClicking".
This way the events should fire as expected.
If any further questions arise, please feel free to ask them.
Kind regards,
Simon
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center