We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Setting defaults for schedule editor repeat values

Hello,

How would I go about setting defaults for the items circled in red in the attached picture? Passing a recurrence rule doesn't seem to work.

I have the class below - creating a new instance of the class and filling in the defaults and then calling OpenEditorAsync works perfectly except for the recurrencerule which is ignored. I pass 

"FREQ=MONTHLY;INTERVAL=1;BYDAY=MO;BYSETPOS=4;"

As the recurrence rule but the editor still opens with Repeat: Never, the other repeat values are defaults as well. How do I make the editor open with the correct

public class AppointmentData
{
    public int? Id { get; set; }
    public string? Subject { get; set; }
    public string? Location { get; set; } = "";
    public string? Description { get; set; }
    public DateTime StartTime { get; set; }
    public DateTime EndTime { get; set; }
    public bool IsAllDay { get; set; }
    public string? RecurrenceRule { get; set; }
    public int? RecurrenceId { get; set; }
    public string? RecurrenceException { get; set; }
    public string? StartTimeZone { get; set; }
    public string? EndTimeZone { get; set; }
}


editor.png


8 Replies

VR Vijay Ravi Syncfusion Team April 5, 2023 12:41 PM UTC

Hi Sheldon,


Ug: https://blazor.syncfusion.com/documentation/scheduler/events#oncelldoubleclick

Api: https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Schedule.SfSchedule-1.html#Syncfusion_Blazor_Schedule_SfSchedule_1_OpenEditorAsync__0_Syncfusion_Blazor_Schedule_CurrentAction_


Below is a sample code to open the editor with the default recurrence rule using OpenEditorAsync. When passing the eventData parameter to OpenEditorAsync, ensure to provide a value in the RecurrenceRule field to open the editor with the default recurrence value.


[index.razor]


@code {

    public async Task OnCellDoubleClick(CellClickEventArgs args)

    {

        args.Cancel = true;

        var ActiveCellsData = await ScheduleRef.GetTargetCellAsync((int)args.MouseEventArgs.ScreenX, (int)args.MouseEventArgs.ScreenY);       

        AppointmentData eventData = new AppointmentData

            {

                Id = await ScheduleRef.GetMaxEventIdAsync<int>(),

                Subject = "Add title",

                StartTime = ActiveCellsData.StartTime,

                EndTime = ActiveCellsData.StartTime.AddHours(1),

                Location = "",

                Description = "",

                IsAllDay = false,

                RecurrenceRule = "FREQ=MONTHLY;BYDAY=MO;BYSETPOS=4;INTERVAL=1"

            };

            await ScheduleRef.OpenEditorAsync(eventData, CurrentAction.Add);

    }


Regards,

Vijay Ravi


Attachment: openEditor_sample_2bf96341.zip


SH Sheldon April 5, 2023 01:14 PM UTC

Hello,

Your zip sample will not load into VS2022 - see pic below with the error



So, when I tried to use your sample code from above 2 thing happened.

Id = await ScheduleRef.GetMaxEventIdAsync<int>() hangs forever - I suspect because there were no existing appointments.

So I took that out and just hard coded a 1 for the Id and then filling in the recurrence rule doesn't work - which was my original point.


Thanks


Sheldon



VR Vijay Ravi Syncfusion Team April 6, 2023 09:20 AM UTC

Hi Sheldon,


You can resolve your reported problem by removing the Id field in the eventData when you call the OpenEditoryAsync method to add a new appointment as shown in the below code snippet. Try the shared sample and if you still facing issues share the below details to proceed further.


  • Reproduce the issue in our shred sample or
  • Issue reproducing sample.
  • Version of the Syncfusion.Blazor.Schedule Nuget that you are using.


[index.cshtml]

<SfSchedule TValue="AppointmentData" @ref="@ScheduleRef" Height="650px" @bind-SelectedDate="@CurrentDate">

    <ScheduleEvents TValue="AppointmentData" OnCellDoubleClick="OnCellDoubleClick"></ScheduleEvents>

  </SfSchedule>

@code {

public async Task OnCellDoubleClick(CellClickEventArgs args)  

{

        args.Cancel = true;

        AppointmentData eventData = new AppointmentData

            {

                Subject = "Add title",

                StartTime = args.StartTime,

                EndTime = args.StartTime.AddHours(1),

                Location = "",

                Description = "",

                IsAllDay = args.IsAllDay,

                RecurrenceRule = "FREQ=MONTHLY;BYDAY=MO;BYSETPOS=4;INTERVAL=1"

            };

            await ScheduleRef.OpenEditorAsync(eventData, CurrentAction.Add);   

    }


Regards,

Vijay Ravi


Attachment: updated_sample_704a532c.zip


SH Sheldon April 6, 2023 12:48 PM UTC

In your sample if you change the ReccurenceRule to FREQ=MONTHLY;INTERVAL=2;BYMONTHDAY=1; you will see it comes up incorrectly. This should be repeat on the 1st every 2 months but comes up as:



You can try and resave it by clicking Day and then opening it and it will be wrong again.


Also in your demo ( as well as my app ), if you save the recurring event and then try Edit Event ( Edit Series works fine ) it crashes




VR Vijay Ravi Syncfusion Team April 7, 2023 08:02 AM UTC

Hi Sheldon,


In your shared code snippet, you are using the Id field of the appointment as nullable which is causing your reported problem. It’s mandatory that each appointment needs to have a unique Id value. So, you can resolve your reported problem by changing the Id type from nullable int to int as highlighted in the below code snippet.


[index.cshtml]

    public class AppointmentData

    {

        public int Id { get; set; }

    }


Regards,

Vijay Ravi


Attachment: updating_sample_94a6289a.zip


SH Sheldon April 7, 2023 08:23 AM UTC

The example you sent me has Id as nullable :) But that does fix the crash. It doesn't fix the fact that saving a recurring event and editing it is being parsed incorrectly. See the top of my previous message. Or just try it in your own sample. Add an event, set it to recur on the first day of every month, save it, edit the series and it will not be what you set it to.


Sheldon



VR Vijay Ravi Syncfusion Team April 10, 2023 10:36 AM UTC

Hi Sheldon


We confirmed your reported problem with "RecurrenceRule comes up incorrectly" as a bug and logged the defect report. The fix for this defect will be included in our upcoming weekly patch release, which is expected to be rolled out on 25th April. You can track the status of the fix at the following link:


Feedbackhttps://www.syncfusion.com/feedback/42758/recurrencerule-comes-up-incorrectly-while-open-the-editor-window


Disclaimer: The inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization.


Regards,

Vijay Ravi



VD Vinitha Devi Murugan Syncfusion Team April 19, 2023 08:52 AM UTC

Hi Sheldon,


The fix for the issue “RecurrenceRule comes up incorrectly” has been included in our weekly release 21.1.41. Upgrade to the latest version to resolve the issue.


Release notes: https://blazor.syncfusion.com/documentation/release-notes/21.1.41?type=all#schedule


Regards,

Vinitha


Loader.
Live Chat Icon For mobile
Up arrow icon