在议程视图中更改rad调度程序的背景颜色

时间:2017-08-02 13:21:02

标签: c# asp.net telerik radscheduler

我在议程视图中有一个rad调度程序。我希望更改调度程序中某些约会的背景颜色。可以看到示例here

这是我当前的C#代码,但背景从未在日程视图中更改。是否可以在议程视图中更改颜色。这适用于任何其他视图。

protected void rs_Calendar_AppointmentDataBound(object sender, SchedulerEventArgs e)
    {
        if (e.Appointment.DataItem is vw_CalendarDate)
        {
            vw_CalendarDate ce = (vw_CalendarDate)e.Appointment.DataItem;
            if (ce.Title != null && ce.Title.ToLower().StartsWith("sgt"))
                e.Appointment.BackColor = Color.Red;
            }

这是调度程序的代码:

<telerik:RadScheduler runat="server" ID="rs_Calendar"
                    SelectedView="AgendaView" 

                    AllowDelete="false"
                    Height="100%" OverflowBehavior="Expand"
                    Width="100%" DataKeyField="TourInstanceId" DataSubjectField="Title"
                    DataStartField="DateStart" DataEndField="DateEnd" 

                    OnAppointmentDataBound="rs_Calendar_AppointmentDataBound"
                     OnAppointmentCreated="RadScheduler1_AppointmentCreated"
                    OnNavigationComplete="rs_Calendar_NavigationComplete"
                    OnClientAppointmentInserting="CancelEvent"
                    OnClientAppointmentEditing="CancelEvent"
                    CustomAttributeNames="Color,TourInstanceId,Title,Bookings,Guideinitials,Availability,GroupName"
                    OnClientAppointmentMoveEnd="MoveAppt"
                    OnClientAppointmentResizeStart="ResizeAppt"
                    OnClientAppointmentClick="onClientAppointmentClick"
                    OnClientAppointmentDoubleClick="onClientAppointmentDoubleClick">
                    <WeekView UserSelectable="false" />
                    <DayView UserSelectable="false" />
                    <MonthView UserSelectable="true" />
                    <MultiDayView UserSelectable="false" />
                    <TimelineView UserSelectable="true" />
                    <AgendaView UserSelectable="true" />
                    <AppointmentTemplate>
                        <div class="appt-title" style="border-color: <%# Eval("Attributes['BackGroundColor']") %>; color: <%# Eval("Attributes['TextColor']") %>;">

                            <span runat="server" id="calendar_icons_alerts">
                                <img class="icons_on_calendar" src="<%# Eval("Attributes['Completed']") %>" alt="Completed" width="20px" style="display: <%# Eval("Attributes['Completed']")!=null ? "inline-block": "none" %>" />
                                <img class="icons_on_calendar" src="<%# Eval("Attributes['Closed']") %>" alt="Closed" width="20px" style="display: <%# Eval("Attributes['Closed']")!=null ? "inline-block": "none" %>" />
                                <img class="icons_on_calendar" src="<%# Eval("Attributes['Custom']") %>" alt="Custom" width="50px" style="display: <%# Eval("Attributes['Custom']")!=null ? "inline-block": "none" %>" />
                                <img class="icons_on_calendar" src="<%# Eval("Attributes['Transfer']") %>" alt="Transfer" width="50px" style="display: <%# Eval("Attributes['Transfer']")!=null ? "inline-block": "none" %>" />
                                <img class="icons_on_calendar" src="<%# Eval("Attributes['Attention']") %>" alt="Attention" width="20px" style="display: <%# Eval("Attributes['Attention']")!=null ? "inline-block": "none" %>" />
                                <img class="icons_on_calendar" src="<%# Eval("Attributes['No Bookings']") %>" alt="No Bookings" width="20px" style="display: <%# Eval("Attributes['No Bookings']")!=null ? "inline-block": "none" %>" />
                                <img class="icons_on_calendar" src="<%# Eval("Attributes['Headsets']") %>" alt="Headsets" width="20px" style="display: <%# Eval("Attributes['Headsets']")!=null ? "inline-block": "none" %>" />
                                <img class="icons_on_calendar" src="<%# Eval("Attributes['Bikes']") %>" alt="Bikes" width="20px" style="display: <%# Eval("Attributes['Bikes']")!=null ? "inline-block": "none" %>" />
                                <img class="icons_on_calendar" src="<%# Eval("Attributes['Tickets']") %>" alt="Tickets" width="20px" style="display: <%# Eval("Attributes['Tickets']")!=null ? "inline-block": "none" %>" />
                                <img class="icons_on_calendar" src="<%# Eval("Attributes['Guide']") %>" alt="Guide" width="20px" style="display: <%# Eval("Attributes['Guide']")!=null ? "inline-block": "none" %>" />
                                <img class="icons_on_calendar" src="<%# Eval("Attributes['Money']") %>" alt="Money" width="20px" style="display: <%# Eval("Attributes['Money']")!=null ? "inline-block": "none" %>" />
                                <img class="icons_on_calendar" src="<%# Eval("Attributes['Kids']") %>" alt="Kids" width="20px" style="display: <%# Eval("Attributes['Kids']")!=null ? "inline-block": "none" %>" />
                                <img class="icons_on_calendar" src="<%# Eval("Attributes['Voucher']") %>" alt="Voucher" width="20px" style="display: <%# Eval("Attributes['Voucher']")!=null ? "inline-block": "none" %>" />
                                <img class="icons_on_calendar" src="<%# Eval("Attributes['Arrange Transfer']") %>" alt="Arrange Transfer" width="20px" style="display: <%# Eval("Attributes['Arrange Transfer']")!=null ? "inline-block": "none" %>" />
                                <img class="icons_on_calendar" src="<%# Eval("Attributes['Radio']") %>" alt="Radio" width="20px" style="display: <%# Eval("Attributes['Radio']")!=null ? "inline-block": "none" %>" />
                                <img class="icons_on_calendar" src="<%# Eval("Attributes['VIP client']") %>" alt="VIP client" width="20px" style="display: <%# Eval("Attributes['VIP client']")!=null ? "inline-block": "none" %>" />
                                <img class="icons_on_calendar" src="<%# Eval("Attributes['Finelli & Shaw']") %>" alt="Finelli & Shaw" width="20px" style="display: <%# Eval("Attributes['Finelli & Shaw']")!=null ? "inline-block": "none" %>" />
                                <img class="icons_on_calendar" src="<%# Eval("Attributes['Trip planning']") %>" alt="Trip planning" width="20px" style="display: <%# Eval("Attributes['Trip planning']")!=null ? "inline-block": "none" %>" />
                                <img class="icons_on_calendar" src="<%# Eval("Attributes['People Together']") %>" alt="People Together" width="20px" style="display: <%# Eval("Attributes['People Together']")!=null ? "inline-block": "none" %>" />
                                <img class="icons_on_calendar" src="<%# Eval("Attributes['Press']") %>" alt="Press" width="20px" style="display: <%# Eval("Attributes['Press']")!=null ? "inline-block": "none" %>" />
                                <img class="icons_on_calendar" src="<%# Eval("Attributes['Restaurant Reservation']") %>" alt="Restaurant Reservation" width="20px" style="display: <%# Eval("Attributes['Restaurant Reservation']")!=null ? "inline-block": "none" %>" />
                                <img class="icons_on_calendar" src="<%# Eval("Attributes['Pick Up Location']") %>" alt="Pick Up Location" width="20px" style="display: <%# Eval("Attributes['Pick Up Location']")!=null ? "inline-block": "none" %>" />
                                <img class="icons_on_calendar" src="<%# Eval("Attributes['Drop Off Location']") %>" alt="Drop Off Location" width="20px" style="display: <%# Eval("Attributes['Drop Off Location']")!=null ? "inline-block": "none" %>" />
                                <img class="icons_on_calendar" src="<%# Eval("Attributes['Meeting Point']") %>" alt="Meeting Point" width="20px" style="display: <%# Eval("Attributes['Meeting Point']")!=null ? "inline-block": "none" %>" />
                            </span>

                            <%# Eval("Subject") %>
                        </div>
                    </AppointmentTemplate>
                </telerik:RadScheduler>

1 个答案:

答案 0 :(得分:0)

问题是约会存储在议程视图的表格中,因此更改约会的背景颜色不会做任何事情。 您必须使用属性来更改表格行的背景颜色