This is a migrated thread and some comments may be shown as answers.

Advanced Form: Grid of checkboxes for recurrence

7 Answers 115 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Ellie
Top achievements
Rank 1
Ellie asked on 19 Feb 2020, 01:55 PM

Hi all,

This is probably going to sound a bit counter-intuitive to the point of this control, but I've been asked to hide the recurrence controls in the scheduler & replace them with a grid of checkboxes for weeks in each term:

e.g. 

T1: x  x   x  _ x  x : put appointment in weeks 1-6 (except 4) of term 1

However they still want the scheduler to recognise this as a recurring appointment so that changes can be made to the series or as an exception.

On 1st glance my thoughts are to grab the 1st & last ticked dates from the check boxes, having pre-ticked the relevant box when the appointment is first made, & work out a recurrence rule with the unticked items as exceptions. We're still at proof of concept stage, but I'd appreciate any ideas on a better way to do this please.

 

7 Answers, 1 is accepted

Sort by
0
Peter Milchev
Telerik team
answered on 20 Feb 2020, 01:03 PM

Hello Ellie,

Your logic seems correct, and indeed this might be possible with a bit of a custom implementation. 

The scheduler saves in the database only the non-recurring appointments, the Master and the Exception appointments. The occurrence appointments are created on the fly based on the Master appointment's recurrence rule.

With that said, you can create the master appointment with the weekly recurrence and based on the checkboxes in the grid, to add the exception dates to the recurrence rule:

Regards,
Peter Milchev
Progress Telerik

Get quickly onboarded and successful with UI for ASP.NET AJAX with the Virtual Classroom technical trainings, available to all active customers. Learn More.
0
Ellie
Top achievements
Rank 1
answered on 25 Feb 2020, 03:31 PM

Thank your for your response.

I've had a go at implementing this & all seems fine for the advanced form in insert mode, but i seem to have an initialisation problem with edit mode.

The RadCheckBoxList is populated from an SqlDataSource that shows week number as text & date as value, with day type (term vs holiday) as the tool tip. I also have ClientEvents-OnLoad="OnClientLoad" that changes the box colour to red or blue based on the DataToolTipField.

If I try to go to the advanced form in edit mode by double clicking or right clicking the loading panel spins for a bit & then the page freezes. Stepping through the code shows everything populating correctly, but no screen. However if I try to insert an appointment 1st & then try to edit an appointment it all loads just fine. 

Ticking the correct check boxes by parsing the recurrence rule seems to be ok on this second load of the advanced form, but the error persists even if comment that code out & just try for a blank checkboxlist.

This says to me there's an initialisation error, but I can't spot it.

Thanks,

Ellie

0
Ellie
Top achievements
Rank 1
answered on 25 Feb 2020, 03:57 PM

Most of the code is straight from the tutorials (**Code placed in a small scrollable element from Admin by request of author**).

Scheduler:

  <telerik:RadScheduler RenderMode="Lightweight" ID="RadScheduler1" runat="server" ProviderName="SchedulerDBProvider"
DayStartTime="07:00:00" DayEndTime="22:30:00"
WorkDayStartTime="07:30:00" WorkDayEndTime="22:00:00" CustomAttributeNames="RequiresRegister,DuringExams"
 FirstDayOfWeek="Monday" LastDayOfWeek="Saturday" StartInsertingInAdvancedForm="true"
SelectedDate="2020-09-07" StartEditingInAdvancedForm="true"
Width="100%" OverflowBehavior="Expand" ShowFooter="False" RowHeight="37px"
OnAppointmentDataBound="RadScheduler1_AppointmentDataBound"
OnAppointmentCreated="RadScheduler1_AppointmentCreated">                           
                            <AdvancedForm Modal="true" />
                            <AppointmentTemplate>
                                <asp:Label runat="server" ID="RecurrenceIcon"></asp:Label>
                                <%# Eval("Subject") %>
                                <br />
                                <asp:Literal runat="server" ID="Groups"></asp:Literal>
                            </AppointmentTemplate>
                            <AdvancedEditTemplate>
                                <sched:AdvancedForm runat="server" ID="AdvancedEditForm1" Mode="Edit" Subject='<%# Bind("Subject") %>'
                                    Start='<%# Bind("Start") %>' End='<%# Bind("End") %>' RecurrenceRuleText='<%# Bind("RecurrenceRule") %>' RequiresRegister='<%# Bind("RequiresRegister") %>' Group='<%# Bind("Group") %>'  />
                            </AdvancedEditTemplate>
                            <AdvancedInsertTemplate>
                                <sched:AdvancedForm runat="server" ID="AdvancedInsertForm1" Mode="Insert" Subject='<%# Bind("Subject") %>'
                                    Start='<%# Bind("Start") %>' End='<%# Bind("End") %>' RecurrenceRuleText='<%# Bind("RecurrenceRule") %>' RequiresRegister='<%# Bind("RequiresRegister") %>' Group='<%# Bind("Group") %>'  />
                            </AdvancedInsertTemplate>
                            <TimeSlotContextMenuSettings EnableDefault="false" />
                            <AppointmentContextMenuSettings EnableDefault="true" />
                        </telerik:RadScheduler>

 

Advanced Form - taken from tutorial & modified a bit

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="AdvancedForm.ascx.cs" Inherits="Scheduler.AdvancedForm" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register TagPrefix="sched" TagName="ResourceControl" Src="ResourceControl.ascx" %>
<%@ Register TagPrefix="sched" TagName="MultipleValuesResourceControl" Src="MultipleValuesResourceControl.ascx" %>
 
<div class="rsDialog rsAdvancedEdit rsAdvancedModal" style="position: relative">
    <%-- Title bar. --%>
    <div class="rsAdvTitle rsTitle">
        <div class="rsAdvInnerTitle">           
            <%= (this.Mode.ToString() == "Edit") ? Owner.Localization.AdvancedEditAppointment : Owner.Localization.AdvancedNewAppointment %>
        </div>
        <asp:LinkButton runat="server" ID="AdvancedEditCloseButton" CssClass="rsAdvEditClose"
            CommandName="Cancel" CausesValidation="false" ToolTip='<%# Owner.Localization.AdvancedClose %>'>
            <span class="p-icon p-i-close"></span>
        </asp:LinkButton>
    </div>
    <div class="rsAdvContentWrapper rsBody">
        <asp:Panel runat="server" ID="AdvOptionsScroll" CssClass="rsAdvOptionsScroll" OnDataBinding="AdvOptionsScroll_DataBinding">
            <ul class="rfbGroup">
                <li class="rfbRow">
                    <telerik:RadComboBox runat="server" ID="SubjectComboBox" AppendDataBoundItems="true" DataTextField="ActivityName" DataValueField="ActivityName" />
                    <asp:RequiredFieldValidator runat="server" ID="SubjectValidator" ControlToValidate="SubjectComboBox"
                        EnableClientScript="true" Display="None" CssClass="rsValidatorMsg" />
                </li>
                <li class="rfbRow rsTimePick">
                    <label class="rfbLabel" for='<%= StartDate.ClientID %>_dateInput_text'>
                        <%= Owner.Localization.AdvancedFrom %></label><%--
                        Leaving a newline here will affect the layout, so we use a comment instead.
                        --%><telerik:RadDatePicker runat="server" ID="StartDate" CssClass="rsAdvDatePicker"
                            SharedCalendarID="SharedCalendar" Culture='<%# Owner.Culture %>'
                            MinDate="1900-01-01" RenderMode="Lightweight">
                            <DateInput ID="DateInput2" runat="server" DateFormat='<%# Owner.AdvancedForm.DateFormat %>'
                                EmptyMessageStyle-CssClass="riError" EmptyMessage=" " />
                        </telerik:RadDatePicker>
                    <%--
                                      
                    --%><telerik:RadTimePicker runat="server" ID="StartTime" CssClass="rsAdvTimePicker"
                            Culture='<%# Owner.Culture %>' RenderMode="Lightweight">
                        <DateInput ID="DateInput3" runat="server" EmptyMessageStyle-CssClass="riError" EmptyMessage=" " />
                        <TimeView ID="TimeView1" runat="server" Columns="2" ShowHeader="false" StartTime="08:00"
                            EndTime="18:00" Interval="00:30" />
                    </telerik:RadTimePicker>
                </li>
                <li class="rfbRow rsTimePick rsEndTimePick">
                    <label class="rfbLabel" for='<%= EndDate.ClientID %>_dateInput_text'>
                        <%= Owner.Localization.AdvancedTo%></label><%--
                                      
                        --%><telerik:RadDatePicker runat="server" ID="EndDate" CssClass="rsAdvDatePicker"
                            SharedCalendarID="SharedCalendar" Culture='<%# Owner.Culture %>'
                            MinDate="1900-01-01" RenderMode="Lightweight">
                            <DateInput ID="DateInput4" runat="server" DateFormat='<%# Owner.AdvancedForm.DateFormat %>'
                                EmptyMessageStyle-CssClass="riError" EmptyMessage=" " />
                        </telerik:RadDatePicker>
                    <%--
                                      
                    --%><telerik:RadTimePicker runat="server" ID="EndTime" CssClass="rsAdvTimePicker"
                        Culture='<%# Owner.Culture %>' RenderMode="Lightweight">
                        <DateInput ID="DateInput5" runat="server" EmptyMessageStyle-CssClass="riError" EmptyMessage=" " />
                        <TimeView ID="TimeView2" runat="server" Columns="2" ShowHeader="false" StartTime="08:00"
                            EndTime="18:00" Interval="00:30" />
                    </telerik:RadTimePicker>
                </li>
                <li class="rfbRow">
                    <asp:RequiredFieldValidator runat="server" ID="StartDateValidator" ControlToValidate="StartDate"
                        EnableClientScript="true" Display="None" CssClass="rsValidatorMsg" />
                    <asp:RequiredFieldValidator runat="server" ID="StartTimeValidator" ControlToValidate="StartTime"
                        EnableClientScript="true" Display="None" CssClass="rsValidatorMsg" />
                    <asp:RequiredFieldValidator runat="server" ID="EndDateValidator" ControlToValidate="EndDate"
                        EnableClientScript="true" Display="None" CssClass="rsValidatorMsg" />
                    <asp:RequiredFieldValidator runat="server" ID="EndTimeValidator" ControlToValidate="EndTime"
                        EnableClientScript="true" Display="None" CssClass="rsValidatorMsg" />
                    <asp:CustomValidator runat="server" ID="DurationValidator" ControlToValidate="StartDate"
                        EnableClientScript="false" Display="Dynamic" CssClass="rsValidatorMsg rsInvalid"
                        OnServerValidate="DurationValidator_OnServerValidate" />
                </li>
                <%-- RESOURCE CONTROLS --%>              
                 <li class="rfbRow">                  
                    <uc1:BooleanAttributeControl ID="RequiresRegisterCheckbox" Label="Requires Register" runat="server" Value="" />
                </li>
                <li class="rfbRow">                  
                    <uc1:BooleanAttributeControl ID="DuringExamsCheckBox" Label="Class continues during exams" runat="server" Value="" />
                </li>
                 
                <li>
                    <sched:MultipleValuesResourceControl runat="server" ID="ResGroup" Type="Group" DisplayLabel="Group" />
                </li>            
            </ul>
          <script>
                function OnClientLoad(sender, args) {                 
                    var count = sender.get_items().length;
                    for (var i = 0; i < count; i++)
                    {
                        var displaytooltip = sender.get_items()[i].get_toolTip();
 
                        if ((String(displaytooltip)) == "H") { sender.get_items()[i]._element.firstChild.style.color = "red"; }
                        else { sender.get_items()[i]._element.firstChild.style.color = "blue"; }
                    }
                }
            </script>
 
            <div style="padding-top:10px;">
            <p>For Weeks</p>
                <table>
                <tr><td style="text-align:right;font-weight:bold;padding-right:5px;">T1</td>
                    <td>
                        <telerik:RadCheckBoxList runat="server" ID="CheckWeeksT1" DataSourceID="SqlWeeksDataSource1" Direction="Horizontal" ClientEvents-OnLoad="OnClientLoad">                          
                           <DataBindings DataTextField="WeekNum" DataValueField="DayDate" DataToolTipField="DayType" />
                        </telerik:RadCheckBoxList>
                    </td></tr>
                <tr><td style="text-align:right;font-weight:bold;padding-right:5px;">T2  </td>
                    <td>
                        <telerik:RadCheckBoxList runat="server" ID="CheckWeeksT2" DataSourceID="SqlWeeksDataSource2" Direction="Horizontal"  ClientEvents-OnLoad="OnClientLoad">
                            <DataBindings DataTextField="WeekNum" DataValueField="DayDate" DataToolTipField="DayType" />
                        </telerik:RadCheckBoxList>
                    </td></tr>
                <tr><td style="text-align:right;font-weight:bold;padding-right:5px;">T3  </td>
                    <td>                      
                        <telerik:RadCheckBoxList runat="server" ID="CheckWeeksT3" Direction="Horizontal" DataSourceID="SqlWeeksDataSource3"  ClientEvents-OnLoad="OnClientLoad">
                            <DataBindings DataTextField="WeekNum" DataValueField="DayDate"  DataToolTipField="DayType" />
                        </telerik:RadCheckBoxList>
                    </td></tr>
            </table>
            </div>
            <div style="padding-top:10px;">
                <p>Rooms</p>
                <telerik:RadGrid ID="gvRooms" runat="server"></telerik:RadGrid>
            </div>
           <%-- <span class="rsAdvResetExceptions">
                <asp:LinkButton runat="server" ID="ResetExceptions" OnClick="ResetExceptions_OnClick" Visible="false" />
            </span>--%>
            <telerik:RadSchedulerRecurrenceEditor runat="server" ID="AppointmentRecurrenceEditor" visible="false" RenderMode="Lightweight" />
            <asp:HiddenField runat="server" ID="OriginalRecurrenceRule" />
            <telerik:RadCalendar runat="server" ID="SharedCalendar" RenderMode="Lightweight"
                CultureInfo='<%# Owner.Culture %>' ShowRowHeaders="false" RangeMinDate="1900-01-01" />
        </asp:Panel>
        <asp:Panel runat="server" ID="ButtonsPanel" CssClass="rsAdvButtonWrapper rsButtons">
            <asp:LinkButton runat="server" ID="UpdateButton" CssClass="rsAdvEditSave rsButton">
                        <span><%= Owner.Localization.Save %></span>
            </asp:LinkButton>
            <asp:LinkButton runat="server" ID="CancelButton" CssClass="rsAdvEditCancel rsButton" CommandName="Cancel"
                CausesValidation="false">
                        <span><%= Owner.Localization.Cancel %></span>
            </asp:LinkButton>
        </asp:Panel>
 
        <asp:SqlDataSource ID="GridDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:APP_SchedulerConnStr %>"
            SelectCommand="SELECT at_id,at_type FROM [ActivityType] WHERE [at_plan_visible]=1"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlWeeksDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:APP_SchedulerConnStr %>"
            SelectCommand="SELECT WeekNum,DayDate,DisplayDate,Avail FROM vAcademicYear WHERE WeekDayNum=DATEPART(dw,@Start) AND DayDate<'2020-12-19'">
            <SelectParameters>
                <asp:ControlParameter ControlID="StartDate" Name="Start" PropertyName="SelectedDate" DbType="DateTime" />
            </SelectParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlWeeksDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:APP_SchedulerConnStr %>"
            SelectCommand="SELECT WeekNum,DayDate,DisplayDate,Avail FROM vAcademicYear WHERE WeekDayNum=DATEPART(dw,@Start) AND DayDate>='2020-12-19' AND DayDate<'2021-04-20'">
            <SelectParameters>
                <asp:ControlParameter ControlID="StartDate" Name="Start" PropertyName="SelectedDate" DbType="DateTime" />
            </SelectParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlWeeksDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:APP_SchedulerConnStr %>"
            SelectCommand="SELECT WeekNum,DisplayDate,DayDate,Avail FROM vAcademicYear WHERE WeekDayNum=DATEPART(dw,@Start) AND DayDate>='2021-04-20'">
            <SelectParameters>
                <asp:ControlParameter ControlID="StartDate" Name="Start" PropertyName="SelectedDate" DbType="DateTime" />
            </SelectParameters>
        </asp:SqlDataSource>
    </div>
</div>

Advanced Form cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
using Telerik.Web.UI;
using Telerik.Web.UI.Scheduler;
 
using Scheduler.Models;
using Scheduler.Models.DAL;
 
namespace Scheduler
{
 
    public enum RadSchedulerAdvancedFormAdvancedFormMode
    {
        Insert, Edit
    }
 
    public partial class AdvancedForm : System.Web.UI.UserControl
    {
        #region Private members
 
        private bool FormInitialized
        {
            get
            {
                return (bool)(ViewState["FormInitialized"] ?? false);
            }
 
            set
            {
                ViewState["FormInitialized"] = value;
            }
        }
 
        private RadSchedulerAdvancedFormAdvancedFormMode mode = RadSchedulerAdvancedFormAdvancedFormMode.Insert;
 
        #endregion
 
        #region Protected properties
 
        protected RadScheduler Owner
        {
            get
            {
                return Appointment.Owner;
            }
        }
 
        protected Appointment Appointment
        {
            get
            {
                SchedulerFormContainer container = (SchedulerFormContainer)BindingContainer;
                return container.Appointment;
            }
        }
 
        #endregion
 
        #region Attributes and resources
 
        [Bindable(BindableSupport.Yes, BindingDirection.TwoWay)]
        public object Group
        {
            get
            {
                return ResGroup.Value;
            }
 
            set
            {
                ResGroup.Value = value;
            }
        }
 
        [Bindable(BindableSupport.Yes, BindingDirection.TwoWay)]
        public string RequiresRegister
        {
            get
            {
                return RequiresRegisterCheckbox.Value.ToString();
            }
 
            set
            {
                if (Mode == RadSchedulerAdvancedFormAdvancedFormMode.Insert)
                {
                    RequiresRegisterCheckbox.Value = "true";
                }
                else
                {
                    RequiresRegisterCheckbox.Value = value;
                }
            }
        }
 
        [Bindable(BindableSupport.Yes, BindingDirection.TwoWay)]
        public string DuringExams
        {
            get
            {
                return DuringExamsCheckBox.Value.ToString();
            }
 
            set
            {
                DuringExamsCheckBox.Value = value;
            }
        }
 
        #endregion
 
        #region Public properties
 
        public RadSchedulerAdvancedFormAdvancedFormMode Mode
        {
            get
            {
                return mode;
            }
            set
            {
                mode = value;
            }
        }
 
        [Bindable(BindableSupport.Yes, BindingDirection.TwoWay)]
        public string Subject
        {
            get
            {
                return SubjectComboBox.SelectedValue;
            }
 
            set
            {
                if (Session["InsertSubject"] != null)
                {
                    SubjectComboBox.SelectedValue = Session["InsertSubject"].ToString();
                }
                else if ((value != null) && (value!=string.Empty))
                {
                    SubjectComboBox.SelectedValue = value;
                }
            }
        }
 
        [Bindable(BindableSupport.Yes, BindingDirection.TwoWay)]
        public DateTime Start
        {
            get
            {
                DateTime result = StartDate.SelectedDate.Value.Date;
 
                TimeSpan time = StartTime.SelectedDate.Value.TimeOfDay;
                result = result.Add(time);
 
                return Owner.DisplayToUtc(result);
            }
 
            set
            {
                StartDate.SelectedDate = Owner.UtcToDisplay(value);
                StartTime.SelectedDate = Owner.UtcToDisplay(value);               
            }
        }
 
        [Bindable(BindableSupport.Yes, BindingDirection.TwoWay)]
        public DateTime End
        {
            get
            {
                DateTime result = EndDate.SelectedDate.Value.Date;
 
                TimeSpan time = EndTime.SelectedDate.Value.TimeOfDay;
                result = result.Add(time);
 
                return Owner.DisplayToUtc(result);
            }
 
            set
            {
                EndDate.SelectedDate = Owner.UtcToDisplay(value);
                EndTime.SelectedDate = Owner.UtcToDisplay(value);
            }
        }
 
 
        [Bindable(BindableSupport.Yes, BindingDirection.TwoWay)]
        public string RecurrenceRuleText
        {
            get
            {
                if (Owner.RecurrenceSupport)
                {
                    bool dateSpecified = StartDate.SelectedDate.HasValue && EndDate.SelectedDate.HasValue;
                    bool timeSpecified = StartTime.SelectedDate.HasValue && EndTime.SelectedDate.HasValue;
 
                    if ((!dateSpecified) ||
                         (!(dateSpecified && timeSpecified)))
                    {
                        return string.Empty;
                    }
 
                    AppointmentRecurrenceEditor.StartDate = Start;
                    AppointmentRecurrenceEditor.EndDate = End;
 
                    List<ButtonListItem> weeks = new List<ButtonListItem>();
                    foreach (ButtonListItem item in CheckWeeksT1.Items)
                    {
                        weeks.Add(item);
                    }
                    foreach (ButtonListItem item in CheckWeeksT2.Items)
                    {
                        weeks.Add(item);
                    }
                    foreach (ButtonListItem item in CheckWeeksT3.Items)
                    {
                        weeks.Add(item);
                    }
 
 
                    string newrule = ReccurenceFromCheckBoxes(weeks, Start, End);
 
                    //RecurrenceRule rrule = AppointmentRecurrenceEditor.RecurrenceRule; //original code
                    RecurrenceRule.TryParse(newrule, out RecurrenceRule rrule);
 
 
                    if (rrule == null)
                    {
                        return string.Empty;
                    }
 
                    if (RecurrenceRule.TryParse(OriginalRecurrenceRule.Value, out RecurrenceRule originalRule))
                    {
                        rrule.Exceptions = originalRule.Exceptions;
                    }
 
                    if (rrule.Range.RecursUntil != DateTime.MaxValue)
                    {
                        rrule.Range.RecursUntil = Owner.DisplayToUtc(rrule.Range.RecursUntil);
 
                        rrule.Range.RecursUntil = rrule.Range.RecursUntil.AddDays(1);
                    }
 
                    return rrule.ToString();
                }
 
                return string.Empty;
            }
 
            set
            {
                RecurrenceRule.TryParse(value, out RecurrenceRule rrule);
 
                if (rrule != null)
                {
                    if (rrule.Range.RecursUntil != DateTime.MaxValue)
                    {
                        DateTime recursUntil = Owner.UtcToDisplay(rrule.Range.RecursUntil);
 
                        if (!IsAllDayAppointment(Appointment))
                        {
                            recursUntil = recursUntil.AddDays(-1);
                        }
 
                        rrule.Range.RecursUntil = recursUntil;
                    }
 
                    AppointmentRecurrenceEditor.RecurrenceRule = rrule;
 
                    OriginalRecurrenceRule.Value = value;
                }
            }
        }
 
        #endregion
 
        protected void Page_Init(object sender, EventArgs e)
        {
            DAL_ActivityType dAL_ActivityType = new DAL_ActivityType();
            List<ActivityType> planType = dAL_ActivityType.GetActivityTypes();
            SubjectComboBox.DataSource = planType;
            SubjectComboBox.DataBind();
        }
 
       protected void Page_Load(object sender, EventArgs e)
        {
 
            UpdateButton.ValidationGroup = Owner.ValidationGroup;
            UpdateButton.CommandName = Mode == RadSchedulerAdvancedFormAdvancedFormMode.Edit ? "Update" : "Insert";          
 
            InitializeStrings();
            InitializeRecurrenceEditor();
 
            if (!FormInitialized)
            {
                UpdateResetExceptionsVisibility();
            }
        }
 
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
 
            if (!FormInitialized)
            {
                if (IsAllDayAppointment(Appointment))
                {
                    EndDate.SelectedDate = EndDate.SelectedDate.Value.AddDays(-1);
                }
 
                FormInitialized = true;
            }
 
            if (Mode == RadSchedulerAdvancedFormAdvancedFormMode.Insert)
            {
                if (StartDate.SelectedDate != null)
                {
 
                    foreach (ButtonListItem item in CheckWeeksT1.Items)
                    {
                        if (Convert.ToDateTime(item.Value) == StartDate.SelectedDate)
                        {
                            item.Selected = true;
                        }
                    }
                    foreach (ButtonListItem item in CheckWeeksT2.Items)
                    {
                        if (Convert.ToDateTime(item.Value) == StartDate.SelectedDate)
                        {
                            item.Selected = true;
                        }
                    }
                    foreach (ButtonListItem item in CheckWeeksT3.Items)
                    {
                        if (Convert.ToDateTime(item.Value) == StartDate.SelectedDate)
                        {
                            item.Selected = true;
                        }
                    }
                }
            }
 
            //if (Mode == RadSchedulerAdvancedFormAdvancedFormMode.Edit)
            //{
            //    RecurrenceRule.TryParse(RecurrenceRuleText, out RecurrenceRule rrule);
 
 
            //    foreach (DateTime occurrence in rrule.Occurrences)
            //    {
            //        foreach (ButtonListItem item in CheckWeeksT1.Items)
            //        {
            //            if (Convert.ToDateTime(item.Value) == occurrence.Date)
            //                item.Selected = true;
            //        }
            //        foreach (ButtonListItem item2 in CheckWeeksT2.Items)
            //        {
            //            if (Convert.ToDateTime(item2.Value) == occurrence.Date)
            //                item2.Selected = true;
            //        }
            //        foreach (ButtonListItem item3 in CheckWeeksT3.Items)
            //        {
            //            if (Convert.ToDateTime(item3.Value) == occurrence.Date)
            //                item3.Selected = true;
            //        }
            //    }
 
            //}
 
        }
 
        protected void AdvOptionsScroll_DataBinding(object sender, EventArgs e)
        {
         //   AllDayEvent.Checked = IsAllDayAppointment(Appointment);
        }
 
        protected void DurationValidator_OnServerValidate(object source, ServerValidateEventArgs args)
        {
            args.IsValid = (End - Start) > TimeSpan.Zero;
        }
 
        protected void ResetExceptions_OnClick(object sender, EventArgs e)
        {
            Owner.RemoveRecurrenceExceptions(Appointment);
            OriginalRecurrenceRule.Value = Appointment.RecurrenceRule;
         //   ResetExceptions.Text = Owner.Localization.AdvancedDone;
        }
 
        #region Private methods
 
        private string ReccurenceFromCheckBoxes(List<ButtonListItem> weeks,DateTime startforrule, DateTime endforrule) //, RadCheckBoxList CheckWeeksT2, RadCheckBoxList CheckWeeksT3)
        {
            string rrule = "";           
            DateTime end = DateTime.MinValue;
            int numoccurrences = 0;
            List<DateTime> skippedDates = new List<DateTime>();
            List<DateTime> exclusionDates = new List<DateTime>();
            TimeSpan time = startforrule.TimeOfDay;
 
 
            foreach (ButtonListItem item in weeks)
            {
                if (item.Selected)
                {
                    numoccurrences += 1;                   
                    if (Convert.ToDateTime(item.Value) > end)
                        end = Convert.ToDateTime(item.Value);
                }
                else
                {
                    if (Convert.ToDateTime(item.Value) > startforrule)
                        skippedDates.Add(Convert.ToDateTime(item.Value));
                }
            }
 
            foreach (DateTime skip in skippedDates)
            {
                if ((skip > startforrule) && (skip < end))
                {
                    numoccurrences += 1;
                    exclusionDates.Add(skip.Add(time));
                }
            }           
 
            int interval = 1;
            RecurrenceRange range = new RecurrenceRange
            {
                Start = startforrule,
                EventDuration = endforrule - startforrule,
                MaxOccurrences = numoccurrences
            };
            RecurrenceDay recurrenceDay = new RecurrenceDay();
            switch (startforrule.DayOfWeek.ToString())
            {
                case "Monday": recurrenceDay = RecurrenceDay.Monday;break;
                case "Tuesday": recurrenceDay = RecurrenceDay.Tuesday; break;
                case "Wednesday": recurrenceDay = RecurrenceDay.Wednesday; break;
                case "Thursday": recurrenceDay = RecurrenceDay.Thursday; break;
                case "Friday": recurrenceDay = RecurrenceDay.Friday; break;
                case "Saturday": recurrenceDay = RecurrenceDay.Saturday; break;
            }
 
            WeeklyRecurrenceRule thisRecurrenceRule = new WeeklyRecurrenceRule(interval, recurrenceDay, range);
             
            if (exclusionDates.Count > 0) {
 
                foreach (DateTime skip in exclusionDates) {
 
                    int hours = Owner.UtcToDisplay(skip).Hour - skip.ToUniversalTime().Hour;                   
                    thisRecurrenceRule.Exceptions.Add(skip.AddHours(hours));
                }
            }
 
            rrule = thisRecurrenceRule.ToString();
            return rrule;
        }
 
 
        private void InitializeStrings()
        {
            SubjectValidator.ErrorMessage = Owner.Localization.AdvancedSubjectRequired;
            SubjectValidator.ValidationGroup = Owner.ValidationGroup;
 
            StartDateValidator.ErrorMessage = Owner.Localization.AdvancedStartDateRequired;
            StartDateValidator.ValidationGroup = Owner.ValidationGroup;
 
            StartTimeValidator.ErrorMessage = Owner.Localization.AdvancedStartTimeRequired;
            StartTimeValidator.ValidationGroup = Owner.ValidationGroup;
 
            EndDateValidator.ErrorMessage = Owner.Localization.AdvancedEndDateRequired;
            EndDateValidator.ValidationGroup = Owner.ValidationGroup;
 
            EndTimeValidator.ErrorMessage = Owner.Localization.AdvancedEndTimeRequired;
            EndTimeValidator.ValidationGroup = Owner.ValidationGroup;
 
            DurationValidator.ErrorMessage = Owner.Localization.AdvancedStartTimeBeforeEndTime;
            DurationValidator.ValidationGroup = Owner.ValidationGroup;
 
            //ResetExceptions.Text = Owner.Localization.AdvancedReset;
 
            SharedCalendar.FastNavigationSettings.OkButtonCaption = Owner.Localization.AdvancedCalendarOK;
            SharedCalendar.FastNavigationSettings.CancelButtonCaption = Owner.Localization.AdvancedCalendarCancel;
            SharedCalendar.FastNavigationSettings.TodayButtonCaption = Owner.Localization.AdvancedCalendarToday;
        }
 
        private void InitializeRecurrenceEditor()
        {
            AppointmentRecurrenceEditor.SharedCalendar = SharedCalendar;
            AppointmentRecurrenceEditor.Culture = Owner.Culture;
            AppointmentRecurrenceEditor.StartDate = Appointment.Start;
            AppointmentRecurrenceEditor.EndDate = Appointment.End;
        }
 
        private void UpdateResetExceptionsVisibility()
        {
            // Render the reset exceptions checkbox when using web service binding
            //if (string.IsNullOrEmpty(Owner.WebServiceSettings.Path))
            //{
            //    ResetExceptions.Visible = false;
            //    if (RecurrenceRule.TryParse(Appointment.RecurrenceRule, out RecurrenceRule rrule))
            //    {
            //        ResetExceptions.Visible = rrule.Exceptions.Count > 0;
            //    }
            //}
        }
 
        private bool IsAllDayAppointment(Appointment appointment)
        {
            DateTime displayStart = Owner.UtcToDisplay(appointment.Start);
            DateTime displayEnd = Owner.UtcToDisplay(appointment.End);
            return displayStart.CompareTo(displayStart.Date) == 0 && displayEnd.CompareTo(displayEnd.Date) == 0;
        }
 
        #endregion
 
    }
}

wefopj

 

 

 

0
Ellie
Top achievements
Rank 1
answered on 26 Feb 2020, 08:57 AM

Ok this is where I wish for a delete button for posts put up in haste.

It's the javascript

0
Peter Milchev
Telerik team
answered on 27 Feb 2020, 12:33 PM

Hello Ellie,

Does your last post "Ok this is where I wish for a delete button for posts put up in haste" mean that you have figured out the issue and you would like to remove your previous response with the code? 

If that is the case, you can tell us which post you would like modified/deleted and we will do it for you.

Another option if you would like, is to share what was the issue and share the custom recurrence handling with the community. That would allow other people to benefit your shared knowledge and we will award Telerik points for it.

Regards,
Peter Milchev
Progress Telerik

Get quickly onboarded and successful with UI for ASP.NET AJAX with the Virtual Classroom technical trainings, available to all active customers. Learn More.
0
Ellie
Top achievements
Rank 1
answered on 27 Feb 2020, 12:41 PM

Yes it does :D.

If you remove the post with all the code I'll put up a much shorter version with the issue & solution so people don't have to scroll through a wall of unnecessary. i will also put up a sample of the finished version when testing is done.

 

Ellie

0
Peter Milchev
Telerik team
answered on 27 Feb 2020, 01:21 PM

Hello Ellie,

That sounds perfect. 

In order to keep the original post, I have made it scrollable with 200px height.

Once you have the final version, you can attach it to a General Feedback ticket or share a link to the project if it exceeds 20MB. Then we can share it here and award you for your efforts.

Regards,
Peter Milchev
Progress Telerik

Get quickly onboarded and successful with UI for ASP.NET AJAX with the Virtual Classroom technical trainings, available to all active customers. Learn More.
Tags
Scheduler
Asked by
Ellie
Top achievements
Rank 1
Answers by
Peter Milchev
Telerik team
Ellie
Top achievements
Rank 1
Share this question
or