Below is the markup for an appointment scheduling interface. There is an DropDownList to select the facility which is populated by an SqlDataSource. Each facility has any number of resources.
On first run all looks like it is working properly, accept the appointments template is not being used. Instead, just a rounded gray box appears in its time slot. When looking at the element in FireBug, there is nothing inside the <div class="rsAptContent"></div> tags. So, I removed the <AppointmentTemplate>, and it works. The subject is displayed. but i cannot figure how my ascx control is broken or breaking the scheduler. The code-behind this control is currently empty.
[BEGIN ScheduledAppointment.ascx]
<%@ Control Language="C#"
AutoEventWireup="true"
CodeBehind="ScheduledAppointment.ascx.cs"
Inherits="org.WhoCo.MIS.Applications.Scheduling.ScheduledAppointment" %>
<asp:Panel runat="server" CssClass="misAppointment">
<asp:Panel runat="server">
</asp:Panel>
</asp:Panel>
[END] (Its just a place holder for now...)
Also, when DblClicking on an open slot or on an appointment the LoadingPanel is displayed and then goes away, but no advanced edit/insert form is displayed. When selecting a different facility from the DropDownList, the same LoadingPanel is displayed, but the change in facility has no effect. The schedule and resources from the last facility in the list is always displayed.
Lastly, changing the date using the DatePicker provided by the scheduler has no effect. Well, it has the same effect as the DropDownList and the DatePicker, but the date does not change.
Below is the complete code from the page minus the <%@ %><html><head><body><form> stuff. Below that is the complete code-behind for the page. The connection strings are handled in the code-behind.
[BEGIN Scheduling.aspx]
<%-- Telerik --%>
<telerik:RadScriptManager ID="ScriptManager" runat="server"
EnableScriptGlobalization="true"
EnableScriptLocalization="true"
EnablePartialRendering="true">
<Scripts>
<asp:ScriptReference Assembly="org.WhoCo.MIS.Site" Name="org.WhoCo.MIS.Localization.Strings.js" />
<asp:ScriptReference Assembly="org.WhoCo.MIS.Site" Name="org.WhoCo.MIS.Applications.Scheduling.Localization.Strings.js" />
<asp:ScriptReference Assembly="org.WhoCo.MIS.Site" Name="org.WhoCo.MIS.Applications.Scheduling.ClientScript.js" />
</Scripts>
</telerik:RadScriptManager>
<telerik:RadAjaxManager ID="AjaxManager" runat="server"
EnableEmbeddedScripts="true"
EnableAJAX="true">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="UpdatedControlsGroup">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="ddlFacilities" />
<telerik:AjaxUpdatedControl ControlID="Scheduler" LoadingPanelID="lpDefault" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="lpDefault" runat="server">
<div class="updateOverlay">
<div class="updateContent">
<asp:Image runat="server"
ImageAlign="Middle"
ImageURL="~/Images/Loading.gif" />
</div>
</div>
</telerik:RadAjaxLoadingPanel>
<%-- /Telerik --%>
<%-- Selections Panel --%>
<asp:Panel runat="server" ID="UpdatedControlsGroup"
BackColor="Transparent"
BorderStyle="None">
<%-- Facilities List --%>
<asp:DropDownList ID="ddlFacilities" runat="server"
DataSourceID="dsFacilities"
AutoPostBack="true"
DataTextField="name"
DataValueField="id">
</asp:DropDownList>
<%-- Scheduler --%>
<telerik:RadScheduler ID="Scheduler" runat="server"
Width="100%" Height="100%"
DataSourceID="dsSchedule"
DataKeyField="id"
DataStartField="start"
DataEndField="end"
DataSubjectField="id"
ShowAllDayRow="false"
ShowViewTabs="true"
WeekView-ReadOnly="true"
MonthView-ReadOnly="true"
TimelineView-ReadOnly="true"
StartEditingInAdvancedForm="true"
StartInsertingInAdvancedForm="true"
GroupBy="Schedulable"
GroupingDirection="Horizontal"
SelectedView="ResourceView"
OnClientTimeSlotContextMenu="WhoCo.MIS.Scheduling.Schedule.OnContextMenu"
OnClientAppointmentCreated="WhoCo.MIS.Scheduling.Appointment.OnCreated"
OnClientAppointmentDoubleClick="WhoCo.MIS.Scheduling.Appointment.OnDoubleClick"
OnFormCreated="Scheduler_FormCreated"
OnAppointmentCreated="Scheduler_AppointmentCreated"
OnAppointmentDataBound="Scheduler_AppointmentDataBound">
<ResourceTypes>
<telerik:ResourceType Name="Schedulable" DataSourceID="dsResources" ForeignKeyField="rid" KeyField="id" TextField="name" AllowMultipleValues="false" />
</ResourceTypes>
<AdvancedForm Modal="true" />
<AppointmentTemplate>
<mis:ScheduledAppointment ID="Appointment" runat="server" />
</AppointmentTemplate>
<AdvancedInsertTemplate>
<mis:AppointmentForm ID="InsertForm" runat="server" Mode="Insert" />
</AdvancedInsertTemplate>
<AdvancedEditTemplate>
<mis:AppointmentForm ID="EditForm" runat="server" Mode="Edit" />
</AdvancedEditTemplate>
</telerik:RadScheduler>
</asp:Panel>
<%-- Data Sources --%>
<%-- Facilities DataSource --%>
<asp:SqlDataSource ID="dsFacilities" runat="server"
SelectCommandType="Text"
SelectCommand="SELECT id, name FROM facilities">
</asp:SqlDataSource>
<%-- Resources DataSource --%>
<asp:SqlDataSource ID="dsResources" runat="server"
SelectCommandType="Text"
SelectCommand="SELECT id, status, sort, name, type FROM resources WHERE facility = @p_facility ORDER BY sort ASC">
<SelectParameters>
<asp:ControlParameter ControlID="ddlFacilities" Name="p_facility" Type="UInt32" />
</SelectParameters>
</asp:SqlDataSource>
<%-- Scheduler DataSource --%>
<asp:SqlDataSource ID="dsSchedule" runat="server"
SelectCommandType="Text"
SelectCommand="SELECT * FROM schedule;">
</asp:SqlDataSource>
[END]
[BEGIN Scheduling.aspx.cs]
using System;
using System.Threading;
using System.Globalization;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
// ...
using Telerik.Web.UI;
namespace org.WhoCo.MIS.Applications.Scheduling {
public partial class Main : System.Web.UI.Page {
#region [ Page Events ]
protected void Page_Load( object sender, EventArgs e ) {
}
protected void Page_Init( object sender, EventArgs e ) {
if( !IsPostBack ) {
// Initialize Components
// Datasources
string dbcc = MIS.Database.Client.Prefix + MIS.Session.User.Client.Code;
// dsFacilities.SelectCommand = "SELECT id, name FROM " + dbcc + ".facilities;";
dsFacilities.ProviderName = ConfigurationManager.ConnectionStrings["DB.MIS.WhoCo.lan"].ProviderName;
dsFacilities.ConnectionString = ConfigurationManager.ConnectionStrings["DB.MIS.WhoCo.lan"].ConnectionString.Replace( "initial catalog=_mis", "initial catalog=" + dbcc );
dsResources.ProviderName = ConfigurationManager.ConnectionStrings["DB.MIS.WhoCo.lan"].ProviderName;
dsResources.ConnectionString = ConfigurationManager.ConnectionStrings["DB.MIS.WhoCo.lan"].ConnectionString.Replace( "initial catalog=_mis", "initial catalog=" + dbcc );
dsSchedule.ProviderName = ConfigurationManager.ConnectionStrings["DB.MIS.WhoCo.lan"].ProviderName;
dsSchedule.ConnectionString = ConfigurationManager.ConnectionStrings["DB.MIS.WhoCo.lan"].ConnectionString.Replace( "initial catalog=_mis", "initial catalog=" + dbcc );
// Logger.Application.DebugFormat( "dsSchedule.ConnectionString == {0}", dsSchedule.ConnectionString );
Scheduler.Culture = Thread.CurrentThread.CurrentUICulture;
// Scheduler.SelectedDate = DateTime.Now;
Scheduler.SelectedDate = DateTime.Parse( "2009-08-12 17:00:00" );
Scheduler.DayStartTime = new TimeSpan( 8, 0, 0 );
Scheduler.DayEndTime = new TimeSpan( 20, 0, 0 );
// Scheduler.TimeZoneOffset = new TimeSpan( 7, 0, 0 );
}
}
#endregion Page Events
#region [ Component Events ]
protected void OnRefresh( object sender, EventArgs args ) {
Scheduler.Rebind();
}
protected void Scheduler_FormCreated(object sender, SchedulerFormCreatedEventArgs e) {
RadScheduler scheduler = (RadScheduler)sender;
switch( e.Container.Mode ) {
case SchedulerFormMode.AdvancedInsert:
break;
case SchedulerFormMode.AdvancedEdit:
break;
default:
// LOG!!!
break;
}
}
protected void Scheduler_AppointmentDataBound( object sender, Telerik.Web.UI.SchedulerEventArgs e ) {
Telerik.Web.UI.Appointment a = e.Appointment;
}
protected void Scheduler_AppointmentCreated( object sender, AppointmentCreatedEventArgs e ) {
Telerik.Web.UI.Appointment a = e.Appointment;
ScheduledAppointment sa = (ScheduledAppointment)e.Container.FindControl( "Appointment" );
}
#endregion Component Events
}
}
[END]
Thanks in advance!
Nick Yearwood
On first run all looks like it is working properly, accept the appointments template is not being used. Instead, just a rounded gray box appears in its time slot. When looking at the element in FireBug, there is nothing inside the <div class="rsAptContent"></div> tags. So, I removed the <AppointmentTemplate>, and it works. The subject is displayed. but i cannot figure how my ascx control is broken or breaking the scheduler. The code-behind this control is currently empty.
[BEGIN ScheduledAppointment.ascx]
<%@ Control Language="C#"
AutoEventWireup="true"
CodeBehind="ScheduledAppointment.ascx.cs"
Inherits="org.WhoCo.MIS.Applications.Scheduling.ScheduledAppointment" %>
<asp:Panel runat="server" CssClass="misAppointment">
<asp:Panel runat="server">
</asp:Panel>
</asp:Panel>
[END] (Its just a place holder for now...)
Also, when DblClicking on an open slot or on an appointment the LoadingPanel is displayed and then goes away, but no advanced edit/insert form is displayed. When selecting a different facility from the DropDownList, the same LoadingPanel is displayed, but the change in facility has no effect. The schedule and resources from the last facility in the list is always displayed.
Lastly, changing the date using the DatePicker provided by the scheduler has no effect. Well, it has the same effect as the DropDownList and the DatePicker, but the date does not change.
Below is the complete code from the page minus the <%@ %><html><head><body><form> stuff. Below that is the complete code-behind for the page. The connection strings are handled in the code-behind.
[BEGIN Scheduling.aspx]
<%-- Telerik --%>
<telerik:RadScriptManager ID="ScriptManager" runat="server"
EnableScriptGlobalization="true"
EnableScriptLocalization="true"
EnablePartialRendering="true">
<Scripts>
<asp:ScriptReference Assembly="org.WhoCo.MIS.Site" Name="org.WhoCo.MIS.Localization.Strings.js" />
<asp:ScriptReference Assembly="org.WhoCo.MIS.Site" Name="org.WhoCo.MIS.Applications.Scheduling.Localization.Strings.js" />
<asp:ScriptReference Assembly="org.WhoCo.MIS.Site" Name="org.WhoCo.MIS.Applications.Scheduling.ClientScript.js" />
</Scripts>
</telerik:RadScriptManager>
<telerik:RadAjaxManager ID="AjaxManager" runat="server"
EnableEmbeddedScripts="true"
EnableAJAX="true">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="UpdatedControlsGroup">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="ddlFacilities" />
<telerik:AjaxUpdatedControl ControlID="Scheduler" LoadingPanelID="lpDefault" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="lpDefault" runat="server">
<div class="updateOverlay">
<div class="updateContent">
<asp:Image runat="server"
ImageAlign="Middle"
ImageURL="~/Images/Loading.gif" />
</div>
</div>
</telerik:RadAjaxLoadingPanel>
<%-- /Telerik --%>
<%-- Selections Panel --%>
<asp:Panel runat="server" ID="UpdatedControlsGroup"
BackColor="Transparent"
BorderStyle="None">
<%-- Facilities List --%>
<asp:DropDownList ID="ddlFacilities" runat="server"
DataSourceID="dsFacilities"
AutoPostBack="true"
DataTextField="name"
DataValueField="id">
</asp:DropDownList>
<%-- Scheduler --%>
<telerik:RadScheduler ID="Scheduler" runat="server"
Width="100%" Height="100%"
DataSourceID="dsSchedule"
DataKeyField="id"
DataStartField="start"
DataEndField="end"
DataSubjectField="id"
ShowAllDayRow="false"
ShowViewTabs="true"
WeekView-ReadOnly="true"
MonthView-ReadOnly="true"
TimelineView-ReadOnly="true"
StartEditingInAdvancedForm="true"
StartInsertingInAdvancedForm="true"
GroupBy="Schedulable"
GroupingDirection="Horizontal"
SelectedView="ResourceView"
OnClientTimeSlotContextMenu="WhoCo.MIS.Scheduling.Schedule.OnContextMenu"
OnClientAppointmentCreated="WhoCo.MIS.Scheduling.Appointment.OnCreated"
OnClientAppointmentDoubleClick="WhoCo.MIS.Scheduling.Appointment.OnDoubleClick"
OnFormCreated="Scheduler_FormCreated"
OnAppointmentCreated="Scheduler_AppointmentCreated"
OnAppointmentDataBound="Scheduler_AppointmentDataBound">
<ResourceTypes>
<telerik:ResourceType Name="Schedulable" DataSourceID="dsResources" ForeignKeyField="rid" KeyField="id" TextField="name" AllowMultipleValues="false" />
</ResourceTypes>
<AdvancedForm Modal="true" />
<AppointmentTemplate>
<mis:ScheduledAppointment ID="Appointment" runat="server" />
</AppointmentTemplate>
<AdvancedInsertTemplate>
<mis:AppointmentForm ID="InsertForm" runat="server" Mode="Insert" />
</AdvancedInsertTemplate>
<AdvancedEditTemplate>
<mis:AppointmentForm ID="EditForm" runat="server" Mode="Edit" />
</AdvancedEditTemplate>
</telerik:RadScheduler>
</asp:Panel>
<%-- Data Sources --%>
<%-- Facilities DataSource --%>
<asp:SqlDataSource ID="dsFacilities" runat="server"
SelectCommandType="Text"
SelectCommand="SELECT id, name FROM facilities">
</asp:SqlDataSource>
<%-- Resources DataSource --%>
<asp:SqlDataSource ID="dsResources" runat="server"
SelectCommandType="Text"
SelectCommand="SELECT id, status, sort, name, type FROM resources WHERE facility = @p_facility ORDER BY sort ASC">
<SelectParameters>
<asp:ControlParameter ControlID="ddlFacilities" Name="p_facility" Type="UInt32" />
</SelectParameters>
</asp:SqlDataSource>
<%-- Scheduler DataSource --%>
<asp:SqlDataSource ID="dsSchedule" runat="server"
SelectCommandType="Text"
SelectCommand="SELECT * FROM schedule;">
</asp:SqlDataSource>
[END]
[BEGIN Scheduling.aspx.cs]
using System;
using System.Threading;
using System.Globalization;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
// ...
using Telerik.Web.UI;
namespace org.WhoCo.MIS.Applications.Scheduling {
public partial class Main : System.Web.UI.Page {
#region [ Page Events ]
protected void Page_Load( object sender, EventArgs e ) {
}
protected void Page_Init( object sender, EventArgs e ) {
if( !IsPostBack ) {
// Initialize Components
// Datasources
string dbcc = MIS.Database.Client.Prefix + MIS.Session.User.Client.Code;
// dsFacilities.SelectCommand = "SELECT id, name FROM " + dbcc + ".facilities;";
dsFacilities.ProviderName = ConfigurationManager.ConnectionStrings["DB.MIS.WhoCo.lan"].ProviderName;
dsFacilities.ConnectionString = ConfigurationManager.ConnectionStrings["DB.MIS.WhoCo.lan"].ConnectionString.Replace( "initial catalog=_mis", "initial catalog=" + dbcc );
dsResources.ProviderName = ConfigurationManager.ConnectionStrings["DB.MIS.WhoCo.lan"].ProviderName;
dsResources.ConnectionString = ConfigurationManager.ConnectionStrings["DB.MIS.WhoCo.lan"].ConnectionString.Replace( "initial catalog=_mis", "initial catalog=" + dbcc );
dsSchedule.ProviderName = ConfigurationManager.ConnectionStrings["DB.MIS.WhoCo.lan"].ProviderName;
dsSchedule.ConnectionString = ConfigurationManager.ConnectionStrings["DB.MIS.WhoCo.lan"].ConnectionString.Replace( "initial catalog=_mis", "initial catalog=" + dbcc );
// Logger.Application.DebugFormat( "dsSchedule.ConnectionString == {0}", dsSchedule.ConnectionString );
Scheduler.Culture = Thread.CurrentThread.CurrentUICulture;
// Scheduler.SelectedDate = DateTime.Now;
Scheduler.SelectedDate = DateTime.Parse( "2009-08-12 17:00:00" );
Scheduler.DayStartTime = new TimeSpan( 8, 0, 0 );
Scheduler.DayEndTime = new TimeSpan( 20, 0, 0 );
// Scheduler.TimeZoneOffset = new TimeSpan( 7, 0, 0 );
}
}
#endregion Page Events
#region [ Component Events ]
protected void OnRefresh( object sender, EventArgs args ) {
Scheduler.Rebind();
}
protected void Scheduler_FormCreated(object sender, SchedulerFormCreatedEventArgs e) {
RadScheduler scheduler = (RadScheduler)sender;
switch( e.Container.Mode ) {
case SchedulerFormMode.AdvancedInsert:
break;
case SchedulerFormMode.AdvancedEdit:
break;
default:
// LOG!!!
break;
}
}
protected void Scheduler_AppointmentDataBound( object sender, Telerik.Web.UI.SchedulerEventArgs e ) {
Telerik.Web.UI.Appointment a = e.Appointment;
}
protected void Scheduler_AppointmentCreated( object sender, AppointmentCreatedEventArgs e ) {
Telerik.Web.UI.Appointment a = e.Appointment;
ScheduledAppointment sa = (ScheduledAppointment)e.Container.FindControl( "Appointment" );
}
#endregion Component Events
}
}
[END]
Thanks in advance!
Nick Yearwood