This is a migrated thread and some comments may be shown as answers.

How can i check in which column the selected cell is?

2 Answers 115 Views
Scheduler and Reminder
This is a migrated thread and some comments may be shown as answers.
Bjorn
Top achievements
Rank 1
Bjorn asked on 27 Jan 2014, 03:38 PM
Situation
In this situation i have 3 resources/columns in the scheduler.
Every resource/column has his own available times.
I have disabled the cells when the time is not available.
I want to drag and drop a appointment in an cell.
It has to check if that cell/timeslot is available.

Problem
I don't know how to check in which column the drag and drop cell is. So it checks all resources/Columns.
If in one resource/column a cell/time is disabled then it gives back that it is not available.

How can i check in which column the selected cell is?

private void radScheduler1_DragDrop(object sender, DragEventArgs e)
        {
DragObject dragObject = e.Data.GetData(typeof(DragObject)) as DragObject;
Point point = this.radScheduler1.PointToClient(new Point(e.X, e.Y));           
SchedulerDayViewGroupedByResourceElement groupedDayViewElement = this.radScheduler1.SchedulerElement.ViewElement as SchedulerDayViewGroupedByResourceElement;
SchedulerCellElement schedulerCell = SchedulerUIHelper.GetCellAtPoint(point, groupedDayViewElement.GetDayViewElements());
SchedulerCellElement schedulerCell2 = SchedulerUIHelper.GetCells(this.radScheduler1).Where(x => x.Date >= schedulerCell.Date && x.Date <= SchedulerCell.Date.AddMinutes(((double)dragObject.Values[Enums.AppointmentFields.Duration])-1)
&& x.Enabled == false).FirstOrDefault();

2 Answers, 1 is accepted

Sort by
0
Bjorn
Top achievements
Rank 1
answered on 28 Jan 2014, 08:55 AM
I have found the solution for my problem: x.FindAncestor<SchedulerViewVisualElement>().View.GetResources()[0].Name == resources[0].Name

Here by the full Linq line.

SchedulerResourceCollection resources
= schedulerCell.FindAncestor<
SchedulerViewVisualElement>().View.GetResources();

SchedulerCellElement schedulerCell2 
= SchedulerUIHelper.GetCells(this.radScheduler1).Where(x =>
x.Date
>= schedulerCell.Date
&& x.Date
<=schedulerCell.Date.AddMinutes(((double)dragObject.Values[Enums.AppointmentFields.Duration])-1)
&& x.FindAncestor<SchedulerViewVisualElement>().View.GetResources()[0].Name
== resources[0].Name
&& x.Enabled
== false).FirstOrDefault();
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 30 Jan 2014, 11:21 AM
Hello Bjorn,

Thank you for contacting Telerik Support.

I would suggest you a simpler approach to get the current resource of a SchedulerCellElement:
private void DragDropBehavior_PreviewDragDrop(object sender, RadDropEventArgs e)
{
    SchedulerCellElement schedulerCell = e.HitTarget as SchedulerCellElement;
    if (schedulerCell != null)
    {
        SchedulerResourceCollection resources = schedulerCell.View.GetResources();
        if (resources != null && resources.Count > 0)
        {
            Resource cellResource = resources.First() as Resource;
            string resourceName = cellResource.Name;
        }
    }
}

Note that RadScheduler has its own DragDropBehavior in order to handle dragging and dropping appointments within the control:
this.radScheduler1.DragDropBehavior.PreviewDragDrop += DragDropBehavior_PreviewDragDrop;

I hope this information helps. Should you have further questions, I would be glad to help.

Regards,
Desislava
Telerik
TRY TELERIK'S NEWEST PRODUCT - APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
Scheduler and Reminder
Asked by
Bjorn
Top achievements
Rank 1
Answers by
Bjorn
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or