我想根据用户使用的视图向用户显示不同的内容。为此,我自定义了 AppointmentTemplate 和 AppointmentCreated 事件。我还想显示具有动态高度的约会,这意味着它们会扩展以填充内容,但在某些日子它什么也没有缩小。发生的事情是在 MonthView 上,只有标题显示在照片中:
这是DayView:照片
这是 AppointmentCreated
protected void sched_AppointmentCreated(object sender, AppointmentCreatedEventArgs e) {
using (DBFactory link = new DBFactory()) {
int evtID = int.Parse(e.Appointment.ID.ToString());
if (evtID == 0) {
evtID = SessionManager.Instance.LastInsertedCalendarEventID;
}
CalendarEvent ce = link.GetCalendarEvent(evtID);
Label lblHeader = (Label)e.Container.FindControl("lblHeader");
Label lblDescription = (Label)e.Container.FindControl("lblDescription");
Label lbldates = (Label)e.Container.FindControl("lbldates");
Label lblParticipants = (Label)e.Container.FindControl("lblParticipants");
Label lblLocale = (Label)e.Container.FindControl("lbllocale");
switch (sched.SelectedView) {
case SchedulerViewType.DayView:
lblLocale.Text = string.Format("{0}", ce.EventLocation1.Location);
lblHeader.Text = string.Format("{0} - {1} ", ce.EventType1.EventTypeName, ce.Subject);
lblDescription.Text = string.Format("{0}", ce.Description);
lbldates.Text = string.Format("{0:hh:mm}h - {1:hh:mm}h", ce.StartDate, ce.EndDate);
lblParticipants.Text = string.Format("{0}", link.GetUsernamesFromEvent(evtID));
break;
case SchedulerViewType.WeekView:
case SchedulerViewType.MonthView:
lblLocale.Text = string.Format("{0}", ce.EventLocation1.Location);
lblHeader.Text = string.Format("{0} - {1} ", ce.EventType1.EventTypeName, ce.Subject);
lblDescription.Text = string.Format("{0}", ce.Description);
lbldates.Text = string.Format("{0:hh:mm}h - {1:hh:mm}h", ce.StartDate, ce.EndDate);
lblParticipants.Text = string.Format("{0}", link.GetInitialsFromEvent(evtID));
break;
}
}
}
这是完整的标记
<tk:RadScheduler ID="sched" runat="server" AppointmentStyleMode="Default" DayEndTime="19:00:00" AllowInsert="true" AllowEdit="true" AllowDelete="true"
EnableDescriptionField="True" FirstDayOfWeek="Monday" LastDayOfWeek="Friday"
ShowNavigationPane="true" ShowFooter="False" StartEditingInAdvancedForm="true"
StartInsertingInAdvancedForm="true" Height="551px"
OnFormCreated="sched_FormCreated"
OnAppointmentCommand="sched_AppointmentCommand"
OnAppointmentCreated="sched_AppointmentCreated"
OnAppointmentDataBound="sched_AppointmentDataBound"
Skin="Web20">
<MonthView AdaptiveRowHeight="true" MinimumRowHeight="50" VisibleAppointmentsPerDay="30"/>
<AdvancedForm Modal="true" />
<ExportSettings OpenInNewWindow="true" FileName="SchedulerExport">
<Pdf PageTitle="Schedule" Author="Telerik" Creator="Telerik" Title="Schedule"></Pdf>
</ExportSettings>
<TimelineView UserSelectable="false" />
<AppointmentContextMenuSettings EnableDefault="true" />
<TimeSlotContextMenuSettings EnableDefault="true" />
<TimeSlotContextMenus>
<tk:RadSchedulerContextMenu ID="SchedulerTimeSlotContextMenu" runat="server">
<Items>
<tk:RadMenuItem Text="New Appointment" Value="CommandAddAppointment" />
</Items>
</tk:RadSchedulerContextMenu>
</TimeSlotContextMenus>
<AppointmentContextMenus>
<tk:RadSchedulerContextMenu runat="server" ID="ContextMenu1">
<Items>
<%--<tk:RadMenuItem Text="Ir para dia" Value="CommandNavigateDay" />--%>
<tk:RadMenuItem Text="Editar" Value="CommandEdit" />
<tk:RadMenuItem Text="Apagar" Value="CommandDelete" />
<%--<tk:RadMenuItem Text="Exportar Para PPF" Value="CommandExport"></tk:RadMenuItem>--%>
</Items>
</tk:RadSchedulerContextMenu>
</AppointmentContextMenus>
<AppointmentTemplate>
<asp:Label runat="server" ID="lblHeader" Font-Bold="true" />
<hr />
<table border="0">
<tr>
<td style=" border-color:transparent;"><span style="font-weight:bold;">Descricao: </span></td>
<td style=" border-color:transparent;"><asp:Label ID="lblDescription" runat="server" /></td>
</tr>
<tr>
<td style=" border-color:transparent;"><span style="font-weight:bold;">Participantes: </span></td>
<td style=" border-color:transparent;"><asp:Label ID="lblParticipants" runat="server" /></td>
</tr>
<tr>
<td style=" border-color:transparent;"><span style="font-weight:bold;">Duracao: </span></td>
<td style=" border-color:transparent;"><asp:Label ID="lblDates" runat="server" /></td>
</tr>
<tr>
<td style=" border-color:transparent;"><span style="font-weight:bold;">Local: </span></td>
<td style=" border-color:transparent;"><asp:Label ID="lblLocale" runat="server" /></td>
</tr>
</table>
</AppointmentTemplate>
<AdvancedInsertTemplate>
<div class="rsAdvancedEdit rsAdvancedModal" style="position: relative; margin-right: -100px">
<div class="rsModalBgTopLeft"></div>
<div class="rsModalBgTopRight"></div>
<div class="rsModalBgBottomLeft"></div>
<div class="rsModalBgBottomRight"></div>
<div class="rsAdvTitle">
<h1 class="rsAdvInnerTitle"><%# Container.Appointment.Owner.Localization.AdvancedNewAppointment %></h1>
<asp:LinkButton runat="server" ID="LinkButton1" CssClass="rsAdvEditClose"
CommandName="Cancel" CausesValidation="false" ToolTip='<%# Container.Appointment.Owner.Localization.AdvancedClose %>'>
<%# Container.Appointment.Owner.Localization.AdvancedClose%>
</asp:LinkButton>
</div>
<div class="rsAdvContentWrapper" style="background-color: #ffffff;">
<table border="0">
<tr>
<td>
<asp:Label runat="server" Text="Sumário" ID="lblSummaryHdr" /></td>
<td colspan="3">
<asp:TextBox ID="txtSubject" runat="server" CssClass="textbox" Columns="60" Text='<%# Bind("Subject") %>' /></td>
<td>
<asp:Label ID="TextBox1" runat="server" Text='<%# Bind("ID") %>' Visible="false" /></td>
</tr>
<tr>
<td>Descrição</td>
<td colspan="3">
<asp:TextBox ID="txtDescription" CssClass="textbox" Columns="60" runat="server" Text='<%# Bind("Description") %>'></asp:TextBox><br />
</td>
</tr>
<tr>
<td>Inicío</td>
<td>
<tk:RadDateTimePicker ID="startInput" SelectedDate='<%# Bind("Start") %>' runat="server"></tk:RadDateTimePicker>
</td>
<td>Fim</td>
<td>
<tk:RadDateTimePicker ID="finishInput" SelectedDate='<%# Bind("End") %>' runat="server"></tk:RadDateTimePicker>
</td>
</tr>
<tr>
<td>Tipo</td>
<td>
<tk:RadComboBox ID="ddlEventType" runat="server" CssClass="combo" />
</td>
<td>Sala</td>
<td>
<tk:RadComboBox ID="ddlLocations" runat="server" CssClass="combo" />
</td>
</tr>
<tr>
<td>Grupos</td>
<td>
<tk:RadComboBox ID="ddlGroups" runat="server" CssClass="combo" CheckBoxes="true" EnableCheckAllItemsCheckBox="true" />
</td>
<td>Usuários</td>
<td>
<tk:RadComboBox ID="ddlUsers" runat="server" CssClass="combo" CheckBoxes="true" EnableCheckAllItemsCheckBox="true" />
</td>
</tr>
</table>
<asp:Panel runat="server" ID="Panel1" CssClass="rsAdvancedSubmitArea">
<div class="rsAdvButtonWrapper">
<asp:LinkButton CommandName="Insert" runat="server" ID="LinkButton2" CssClass="rsAdvEditSave">
<span><%# Container.Appointment.Owner.Localization.Save%></span>
</asp:LinkButton>
<asp:LinkButton runat="server" ID="LinkButton3" CssClass="rsAdvEditCancel" CommandName="Cancel" CausesValidation="false">
<span><%# Container.Appointment.Owner.Localization.Cancel%></span>
</asp:LinkButton>
</div>
</asp:Panel>
</div>
</div>
</AdvancedInsertTemplate>
<AdvancedEditTemplate>
<div class="rsAdvancedEdit rsAdvancedModal" style="position: relative; margin-right: -100px">
<div class="rsModalBgTopLeft"></div>
<div class="rsModalBgTopRight"></div>
<div class="rsModalBgBottomLeft"></div>
<div class="rsModalBgBottomRight"></div>
<div class="rsAdvTitle">
<h1 class="rsAdvInnerTitle"><%# Container.Appointment.Owner.Localization.AdvancedEditAppointment %></h1>
<asp:LinkButton runat="server" ID="LinkButton4" CssClass="rsAdvEditClose"
CommandName="Cancel" CausesValidation="false" ToolTip='<%# Container.Appointment.Owner.Localization.AdvancedClose %>'>
<%# Container.Appointment.Owner.Localization.AdvancedClose%>
</asp:LinkButton>
</div>
<div class="rsAdvContentWrapper" style="background-color: #ffffff;">
<table>
<tr>
<td>Sumário</td>
<td colspan="3">
<asp:TextBox ID="txtSubject" runat="server" CssClass="textbox" Columns="60" Text='<%# Bind("Subject") %>' /></td>
</tr>
<tr>
<td>Descrição</td>
<td colspan="3">
<asp:TextBox ID="txtDescription" CssClass="textbox" Columns="60" runat="server" Text='<%# Bind("Description") %>'></asp:TextBox><br />
</td>
</tr>
<tr>
<td>Inicío</td>
<td>
<tk:RadDateTimePicker ID="RadDateTimePicker1" SelectedDate='<%# Bind("Start") %>' runat="server"></tk:RadDateTimePicker>
</td>
<td>Fim</td>
<td>
<tk:RadDateTimePicker ID="RadDateTimePicker2" SelectedDate='<%# Bind("End") %>' runat="server"></tk:RadDateTimePicker>
</td>
</tr>
<tr>
<td>Tipo</td>
<td>
<tk:RadComboBox ID="RadComboBox1" runat="server" CssClass="combo" />
</td>
<td>Sala</td>
<td>
<tk:RadComboBox ID="ddlLocations" runat="server" CssClass="combo" />
</td>
</tr>
<tr>
<td>Grupos</td>
<td>
<tk:RadComboBox ID="RadComboBox3" runat="server" CssClass="combo" CheckBoxes="true" EnableCheckAllItemsCheckBox="true" />
</td>
<td>Usuários</td>
<td>
<tk:RadComboBox ID="RadComboBox4" runat="server" CssClass="combo" CheckBoxes="true" EnableCheckAllItemsCheckBox="true" />
</td>
</tr>
<tr>
<td>Privado</td>
<td colspan="3">
<asp:CheckBox runat="server" ID="CheckBox1" AutoPostBack="false" Checked="false" />
</td>
</tr>
</table>
<asp:Panel runat="server" ID="Panel2" CssClass="rsAdvancedSubmitArea">
<div class="rsAdvButtonWrapper">
<asp:LinkButton CommandName="Update" runat="server" ID="LinkButton5" CssClass="rsAdvEditSave">
<span><%# Container.Appointment.Owner.Localization.Save%></span>
</asp:LinkButton>
<asp:LinkButton runat="server" ID="LinkButton6" CssClass="rsAdvEditCancel" CommandName="Cancel" CausesValidation="false">
<span><%# Container.Appointment.Owner.Localization.Cancel%></span>
</asp:LinkButton>
</div>
</asp:Panel>
</div>
</div>
</AdvancedEditTemplate>
</tk:RadScheduler>