Need More Info
Last Updated: 23 Jan 2024 16:04 by ADMIN
DRASKO
Created on: 28 Dec 2023 15:25
Category: Scheduler
Type: Bug Report
0
SchedulerEditEventArgs wrong End value

When adding / editing the last time slot for the day, SchedulerEditEventArgs has wrong End value.

For example Start value is 28.12.2023. 23:30:00 and end value is 28.12.2023. 00:00:00. Should instead be 28.12.2023. 23:59:59 or 29.12.2023. 00:00:00.

 

3 comments
ADMIN
Hristian Stefanov
Posted on: 23 Jan 2024 16:04

Hi Drasko,

I appreciate the additional details you provided.

In light of this information, I made another attempt to reproduce the issue, yet I still find myself unable to do so. The "args.End" seems correct on my end.

Below is the sample I'm currently testing with. Could you modify it to reproduce the problem and then share it back with me? This will enable me to witness the behavior firsthand and delve deeper into the investigation.

<TelerikScheduler Data="@Appointments"
                  OnUpdate="@UpdateAppointment"
                  OnCreate="@AddAppointment"
                  OnDelete="@DeleteAppointment"
                  OnEdit="@EditHandler" OnCancel="@CancelHandler"
                  AllowCreate="true" AllowDelete="true" AllowUpdate="true"
                  @bind-Date="@StartDate" Height="600px" @bind-View="@CurrView">
    <SchedulerViews>
        <SchedulerDayView StartTime="@DayStart" />
        <SchedulerWeekView StartTime="@DayStart" />
        <SchedulerMultiDayView StartTime="@DayStart" NumberOfDays="10" />
    </SchedulerViews>
</TelerikScheduler>

@code {
    private SchedulerView CurrView { get; set; } = SchedulerView.Week;
    private DateTime StartDate { get; set; } = new DateTime(2019, 12, 2);
    private DateTime DayStart { get; set; } = new DateTime(2000, 1, 1, 8, 0, 0);

    private List<SchedulerAppointment> Appointments { get; set; }

    private async Task UpdateAppointment(SchedulerUpdateEventArgs args)
    {
        SchedulerAppointment item = (SchedulerAppointment)args.Item;

        await MyService.Update(item);

        await GetSchedulerData();
    }

    private async Task AddAppointment(SchedulerCreateEventArgs args)
    {
        SchedulerAppointment item = args.Item as SchedulerAppointment;

        await MyService.Create(item);

        await GetSchedulerData();
    }

    private async Task DeleteAppointment(SchedulerDeleteEventArgs args)
    {
        SchedulerAppointment item = (SchedulerAppointment)args.Item;

        await MyService.Delete(item);

        await GetSchedulerData();
    }

    private void EditHandler(SchedulerEditEventArgs args)
    {
        SchedulerAppointment item = args.Item as SchedulerAppointment;
        if (!args.IsNew) // an edit operation, otherwise - an insert operation
        {
            if (item.Title.Contains("vet", StringComparison.InvariantCultureIgnoreCase))
            {
                args.IsCancelled = true;
            }
        }
        else
        {
            DateTime SlotStart = args.Start; // the start of the slot the user clicked
            DateTime SlotEnd = args.End; // the start of the slot the user clicked
            bool InsertInAllDay = args.IsAllDay; // whether the user started insertion in the All Day row
        }
    }

    private void CancelHandler(SchedulerCancelEventArgs args)
    {
        SchedulerAppointment item = args.Item as SchedulerAppointment;
    }

    public class SchedulerAppointment
    {
        public Guid Id { get; set; }
        public string Title { get; set; }
        public string Description { get; set; }
        public DateTime Start { get; set; }
        public DateTime End { get; set; }
        public bool IsAllDay { get; set; }
        public string RecurrenceRule { get; set; }
        public List<DateTime> RecurrenceExceptions { get; set; }
        public Guid? RecurrenceId { get; set; }

        public SchedulerAppointment()
        {
            Id = Guid.NewGuid();
        }
    }

    private async Task GetSchedulerData()
    {
        Appointments = await MyService.Read();
    }

    protected override async Task OnInitializedAsync()
    {
        await GetSchedulerData();
    }

    private static class MyService
    {
        private static List<SchedulerAppointment> _data { get; set; } = new List<SchedulerAppointment>()
        {
            new SchedulerAppointment
            {
                Title = "Board meeting",
                Description = "Q4 is coming to a close, review the details.",
                Start = new DateTime(2019, 12, 5, 10, 00, 0),
                End = new DateTime(2019, 12, 5, 11, 30, 0)
            },

            new SchedulerAppointment
            {
                Title = "Vet visit",
                Description = "The cat needs vaccinations and her teeth checked.",
                Start = new DateTime(2019, 12, 2, 11, 30, 0),
                End = new DateTime(2019, 12, 2, 12, 0, 0)
            },

            new SchedulerAppointment
            {
                Title = "Planning meeting",
                Description = "Kick off the new project.",
                Start = new DateTime(2019, 12, 6, 9, 30, 0),
                End = new DateTime(2019, 12, 6, 12, 45, 0)
            },

            new SchedulerAppointment
            {
                Title = "Trip to Hawaii",
                Description = "An unforgettable holiday!",
                IsAllDay = true,
                Start = new DateTime(2019, 11, 27),
                End = new DateTime(2019, 12, 05)
            },

            new SchedulerAppointment
            {
                Title = "Morning run",
                Description = "Some time to clear the head and exercise.",
                Start = new DateTime(2019, 11, 27, 9, 0, 0),
                End = new DateTime(2019, 11, 27, 9, 30, 0),
                RecurrenceRule = "FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR"
            }
        };

        public static async Task Create(SchedulerAppointment itemToInsert)
        {
            itemToInsert.Id = Guid.NewGuid();
            _data.Insert(0, itemToInsert);
        }

        public static async Task<List<SchedulerAppointment>> Read()
        {
            return await Task.FromResult(_data);
        }

        public static async Task Update(SchedulerAppointment itemToUpdate)
        {
            var index = _data.FindIndex(i => i.Id == itemToUpdate.Id);
            if (index != -1)
            {
                _data[index] = itemToUpdate;
            }
        }

        public static async Task Delete(SchedulerAppointment itemToDelete)
        {
            if (itemToDelete.RecurrenceId != null)
            {
            }

            if (!string.IsNullOrEmpty(itemToDelete.RecurrenceRule) && itemToDelete.RecurrenceExceptions?.Count > 0)
            {
            }

            _data.Remove(itemToDelete);
        }
    }
}

I eagerly anticipate hearing back from you.

Regards,
Hristian Stefanov
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources!
DRASKO
Posted on: 17 Jan 2024 08:30

Hello Hristian,

Thank you for the quick response. It seems that you misunderstood the problem. I am not trying to input any values, I am talking about the SchedulerEditEventArgs type that contains the arguments of the Edit event that happens when I double click on a time slot in the scheduler control.

I am actually using the scheduler for a slightly different purpose which is irrelevant to the issue, but for which I have had to create a custom edit form as is explained in the Telerik documentation for the Scheduler control.

So, the problem is when I double click on the last time slot for the day (see attached image), the Edit event handler that I implemented receives SchedulerEditEventArgs with the End property having a value as shown in the screenshot that I attached.

Please take a look at the attached images and read my original comment.

I did work around the issue, but it should probably be fixed.

Thank you.

Attached Files:
ADMIN
Hristian Stefanov
Posted on: 04 Jan 2024 12:59

Hi Drasko,

Based on my understanding, it seems that when editing the last time slot, you input a start date of "28.12.2023, 23:30:00" and an end date of "28.12.2023, 00:00:00". I attempted to replicate this scenario using these values, and the Scheduler exhibited validation restrictions, preventing the setting of these dates because "28.12.2023, 00:00:00" precedes "28.12.2023, 23:30:00". I've attached a screenshot for your reference.

This outcome has prompted me to realize that my understanding of the situation might not be entirely clear. To better assist you, could you provide additional details on the specific issue you're encountering and provide steps to reproduce it?

I stand ready to provide prompt assistance once I hear back from you.

Regards,
Hristian Stefanov
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources!
Attached Files: