Highlight a number of cells

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

    Posted 09 Apr 2009 Link to this post

    if i have a schedule that is setup as monthly view is it possible to find out the date range of the number of cells selected?

    e.g. schedule is loaded and i highlight 2nd April - 16th April. i then click a button outside of the schedule - i want to be able to know the date range that has been highlighted?

    i was trying to use the CellClick event even to loop through all cells and check which have been selected. but i cant find a way to loop through the cells?
    foreach (SchedulerCellElement cell in ???)   
    {  
    if (cell.Selected == true)   
        {  
            MessageBox.Show(cell.Date.ToString());   
        }  

    Cheers,
    Craig
  2. Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 10 Apr 2009 Link to this post

    Hello Craig Gamble,

    We will think about providing public API which will help users to manage the selection in RadScheduler.

    You can now find the instances of SchedulerCellElement and check for the Selected property value. You can do this by using the Children collection of the visual elements. RadScheduler has a property named SchedulerVisualElement - this is the root of visual elements in the control. SchedulerVisualElement has a property named ViewElement - this is an instance. The element purpose is to be a container of the specific elements such as SchedulerDayViewElement, SchedulerMultiDayViewElement and SchedulerMonthViewElement so one of the child elements of SchedulerVisualElement will be an instance of the classes I've just pointed. What comes next is to play with the children collection of those elements because they do not have appropriate API to access every single instance.

    For example to get the Children collection of the MonthView you should use something like:

             SchedulerMonthViewElement monthView = this.radScheduler1.SchedulerElement.ViewElement as SchedulerMonthViewElement; 
                RadElementCollection childrenCollection = monthView.Children[1].Children;           
        
    I hope this helps.

    Best wishes,
    Boyko Markov
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  3. Craig Gamble
    Craig Gamble avatar
    71 posts
    Member since:
    Aug 2005

    Posted 10 Apr 2009 Link to this post

    cheers.

    where can the RadElementCollection be found?

    i have the following

    using

     

    Telerik.WinControls.UI;

     

    using

     

    Telerik.WinControls.UI.Scheduler;

     



  4. Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 13 Apr 2009 Link to this post

    Hello Craig Gamble,

    RadElementCollection is part of Telerik.WinControls namespace. You can use the following syntax:

    Telerik.WinControls.RadElementCollection  

    I hope this helps.

    Kind regards,
    Boyko Markov
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  5. Craig Gamble
    Craig Gamble avatar
    71 posts
    Member since:
    Aug 2005

    Posted 15 Apr 2009 Link to this post

    still having a few problems with this.....

    1. if i highlight 4 cells in a monthview it doesnt see them as being selected?? it just passes by them - always has the selected = false even though they where highlighted

    2. if an appointment already exists on certain day then the foreach falls over as it sees this as an AppointmentElement and not a SchedulerCellElement

                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 (SchedulerCellElement cell  in childrenCollection)  
                {  
                    if (cell.Selected == true)  
                    {  
                        if (startDate == DateTime.MinValue)  
                        {  
                            startDate = cell.Date;  
                            endDate = startDate;  
                        }  
                        else 
                        {  
                            endDate = cell.Date;  
                        }  
                    }  
                }  
     
  6. Craig Gamble
    Craig Gamble avatar
    71 posts
    Member since:
    Aug 2005

    Posted 15 Apr 2009 Link to this post

    some more info on issue #2

    the monthview is setup as a 5 week view (30/Mar/09 - 03/May/09) - so there should be 35 items in the childrenCollection but there is actually 37? and it is running over into the next monthview which isnt visible as yet - and i think this is causing the appointmentelement error? as i have existing appointments within the current visible monthView and these are not causing an issues?

  7. Answer
    Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 17 Apr 2009 Link to this post

    Hello Craig Gamble,

    In the case of MonthView you should use MonthCellElement and its Header property. Here's an example:

    SchedulerMonthViewElement monthView = this.radScheduler.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; 
                            endDate = startDate; 
                        } 
                        else 
                        { 
                            endDate = cell.Date; 
                        } 
                    } 
                } 

    Please contact me again if you have more questions.

    Kind regards,
    Boyko Markov
    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.
  8. Craig Gamble
    Craig Gamble avatar
    71 posts
    Member since:
    Aug 2005

    Posted 21 Apr 2009 Link to this post

    cheers, that worked fine.
Back to Top