Create appointment from time range selection

1 Answer 104 Views
ScheduleView
Ola
Top achievements
Rank 1
Ola asked on 21 Mar 2023, 12:28 PM

I just started to work with the ScheduleView, so maybe this is a newbie question.

I want to create an appointment after I have selected a timerange in the ScheduleView (on MouseUp). I need the corresponding resources to be set, but apart from that only start and end should be set on the new appointment.

Should I involve the DragDropManager or can it be solved with events on the ScheduleView only?

Best regard

Ola Nygren

1 Answer, 1 is accepted

Sort by
0
Stenly
Telerik team
answered on 24 Mar 2023, 11:12 AM

Hello Ola Nygren,

To achieve this requirement, you could subscribe to the MouseUp event of RadScheduleView. Then, using the CreateAppointment/CreateAppointmentWithDialog commands, you could create an appointment with the selected time range. These commands are exposed by the RadScheduleViewCommands class.

The following code snippet shows this suggestion's implementation:

private void RadScheduleView_MouseUp(object sender, MouseButtonEventArgs e)
{
    RadScheduleView radScheduleView = (RadScheduleView)sender;

    RadScheduleViewCommands.CreateAppointmentWithDialog.Execute(null, radScheduleView);
}

With this being said, I have attached a sample project for you to test.

Regards,
Stenly
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Ola
Top achievements
Rank 1
commented on 14 Apr 2023, 01:38 PM

Thank you Stenly,

I have been able to test this now and it works. However, I also get the MouseUp when I click delete on an appointment. I have almost been able to prevent a new appointment to be created from the delete button be null-checking the SelectedSlot property and set it to null when I create a new appointment from MouseUp. If I make a slot selection with keyboard and then click delete I will still get a new appointment. Any ideas how to prevent this?

Another related thing I need to accomplish that seems a little trickier is merge appointment where there are overlaps. If I move an appointment so that it overlaps one or more other appointments or if I create an appointment with overlap, these need to be merged into one appointment. I have tried to do the merging in the viewmodel, but RadScheduleView does not like to have the appointment-list manipulated while adding a new appointment. Do you have any ideas to this problem as well? :)

Best regards,

Ola, Tennotech

Stenly
Telerik team
commented on 02 May 2023, 12:54 PM

Hello Ola, 

I was not able to reproduce the behavior from the first question. On my side, when the delete button of an appointment is clicked, the logic inside the added handler for the MouseUp event of RadScheduleView is not executed. Could you try modifying the project from my above reply to mirror the behavior present on your end?

Regarding the second question, may I ask if you could give the suggested approach from the following forum thread a try?

RadScheduleView - Appointments Drag & Merge (telerik.com)

Tags
ScheduleView
Asked by
Ola
Top achievements
Rank 1
Answers by
Stenly
Telerik team
Share this question
or