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

3 posts, 0 answers
  1. Bjorn
    Bjorn avatar
    4 posts
    Member since:
    Jan 2014

    Posted 27 Jan 2014 Link to this post

    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.

    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. Bjorn
    Bjorn avatar
    4 posts
    Member since:
    Jan 2014

    Posted 28 Jan 2014 in reply to Bjorn Link to this post

    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<

    SchedulerCellElement schedulerCell2 
    = SchedulerUIHelper.GetCells(this.radScheduler1).Where(x =>
    >= schedulerCell.Date
    && x.Date
    && x.FindAncestor<SchedulerViewVisualElement>().View.GetResources()[0].Name
    == resources[0].Name
    && x.Enabled
    == false).FirstOrDefault();
  3. DevCraft banner
  4. Dess
    Dess avatar
    1561 posts

    Posted 30 Jan 2014 Link to this post

    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.

    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 >>
Back to Top