Get specific appointment element from scheduler

1 Answer 42 Views
Scheduler and Reminder
Tibor
Top achievements
Rank 1
Iron
Tibor asked on 02 Oct 2023, 08:06 AM

Hi! 

In my code I'm creating new appointments in a scheduler by dropping them from a radGridView. Any ideas how can I get the last created appointment element of the scheduler, or the appointment element assigned to the newly created appointment?

private void svc_PreviewDragDrop(object sender, RadDropEventArgs e)
        {
            SchedulerCellElement schedulerCell = e.HitTarget as SchedulerCellElement;

            if (schedulerCell != null)
            {
                GridDataRowElement draggedRow = e.DragInstance as GridDataRowElement;
                if (draggedRow != null)
                {
                    if (draggedRow.Data.DataBoundItem != null)
                    {
                        if (draggedRow.GridControl.DataSource != null)
                        {
                            MainJobObject draggedMainJobObject = (MainJobObject)draggedRow.Data.DataBoundItem;
                            AppointmentWithObject appointment = new AppointmentWithObject(schedulerCell.Date, schedulerCell.Date.AddHours(1), draggedMainJobObject.Customer, " / ", draggedMainJobObject.MachineType);
                            appointment.Start = schedulerCell.Date;
                            appointment.End = schedulerCell.Date.AddHours(1);
                            appointment.AssignedMainJobObject = draggedMainJobObject;
                            appointment.ResourceId = schedulerCell.View.GetResourceId();
                            scheduler.Appointments.Add(appointment);

                            //CustomAppointmentElement appointmentElement = get the appointment element that was just created;
                            //if (appointmentElement != null)
                            //{
                            //    appointmentElement.ChangeStatus(2);
                            //}                         
                        }
                    }
                }            
            }          
        }


1 Answer, 1 is accepted

Sort by
1
Accepted
Nadya | Tech Support Engineer
Telerik team
answered on 02 Oct 2023, 11:42 AM

Hello, Tibor,

The Appointment is the logical element while the AppointmentElement is its visual representation.  You can use the GetAppointmentElement method which gets the AppointmentElement associated with a specified Appointment:

this.radScheduler1.SchedulerElement.GetAppointmentElement(appointment);

I hope this helps. If you have any other questions, please let me know. 

Regards,
Nadya
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tibor
Top achievements
Rank 1
Iron
commented on 03 Oct 2023, 08:21 AM

It works, thanks a lot for the help!
Tags
Scheduler and Reminder
Asked by
Tibor
Top achievements
Rank 1
Iron
Answers by
Nadya | Tech Support Engineer
Telerik team
Share this question
or