Find appointment details while looping through MonthView

3 posts, 1 answers
  1. Craig Gamble
    Craig Gamble avatar
    71 posts
    Member since:
    Aug 2005

    Posted 21 Apr 2009 Link to this post

    i currently loop through a month view to find out if certain cells have been selected

                SchedulerMonthViewElement monthView = this.schRates.SchedulerElement.ViewElement as SchedulerMonthViewElement;  
                Telerik.WinControls.RadElementCollection childrenCollection = monthView.Children[1].Children;  
     
     
                DateTime startDate = DateTime.MinValue;  
                DateTime endDate = DateTime.MinValue;    
     
     
                foreach (MonthCellElement cell in childrenCollection)  
                {  
                    if (cell.Header.Selected == true)  
                    {  
                        if (startDate == DateTime.MinValue)  
                        {  
                            startDate = cell.Date;  
                        }  
                        else  
                        {  
                            endDate = cell.Date;  
                        }  
                    }  
     
                    if (childrenCollection.IndexOf(cell) == 34)  
                    { break; }  
                } 

    i need to expand upon this, and check if any appointments already exist on a selected cell but cant seem to find any property or method within the cell item that will allow me to check this.

    any help is greatly appreciated.

    Cheers,
    Craig
  2. Answer
    Jordan
    Admin
    Jordan avatar
    547 posts

    Posted 21 Apr 2009 Link to this post

    Hello Craig Gamble,

    It will be easy to get the appointments that intersect with the selected interval by using the IntersectsWith method of the DateTimeInterval class like bellow:

    DateTime start = DateTime.Today.AddHours(12.0); 
                DateTimeInterval selectedInterval = new DateTimeInterval(start, start.AddHours(6.0)); 
                List<IEvent> selectedAppointments = new List<IEvent>(); 
     
                foreach (IEvent appointment in this.radScheduler1.ActiveView.Appointments) 
                { 
                    DateTimeInterval appointmentInterval = new DateTimeInterval(appointment.Start, appointment.End); 
                    if (selectedInterval.IntersectsWith(appointmentInterval)) 
                    { 
                        selectedAppointments.Add(appointment); 
                    } 
                } 

    I hope this helps.

    Regards,
    Jordan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Craig Gamble
    Craig Gamble avatar
    71 posts
    Member since:
    Aug 2005

    Posted 21 Apr 2009 Link to this post

    Good stuff

    Cheers,
    Craig
Back to Top