Resource grouped RadScheduler drag & drop - get the assigned resource of the target cell

1 Answer 43 Views
Scheduler and Reminder
Tibor
Top achievements
Rank 1
Iron
Tibor asked on 27 Sep 2023, 09:21 AM | edited on 27 Sep 2023, 12:40 PM

I have a timeline view scheduler grouped by Resources and would like to use the drag & drop service to move objects from my DataGridView to the scheduler. How do I determine the resource assigned to the cell that's my hit target (the cell I'm currently dropping into), so I can correctly set the ResourceID for the appointment I'm creating?

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)
                    {
                        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.ResourceId = -- I need the resource ID HERE
                        scheduler.Appointments.Add(appointment);                     
                    }
                }            
            }          
        }

 

If it's not possible, I'd be happy with any trick or workaround that helps determining the resource that's assigned to the row the cell currently resides in - even determining the row number of the cell would help.

1 Answer, 1 is accepted

Sort by
1
Accepted
Stephan
Top achievements
Rank 3
Bronze
Iron
Iron
answered on 28 Sep 2023, 08:20 AM | edited on 28 Sep 2023, 08:22 AM
You can get the resource by:

schedulerCell.View.GetResourceId()

or

schedulerCell.View.GetResource()

Tibor
Top achievements
Rank 1
Iron
commented on 28 Sep 2023, 08:25 AM

Wow, it works, thanks!
Nadya | Tech Support Engineer
Telerik team
commented on 28 Sep 2023, 09:57 AM

Hello, Tibor,

Thank you, @Stephan for posting your answer here.

Using the GetResourceId method is the correct way to get the ResourceId of the target SchedulerCellElement

Tags
Scheduler and Reminder
Asked by
Tibor
Top achievements
Rank 1
Iron
Answers by
Stephan
Top achievements
Rank 3
Bronze
Iron
Iron
Share this question
or