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

Highlight a number of cells

7 Answers 165 Views
Scheduler and Reminder
This is a migrated thread and some comments may be shown as answers.
Craig Gamble
Top achievements
Rank 1
Craig Gamble asked on 09 Apr 2009, 09:18 AM
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

7 Answers, 1 is accepted

Sort by
0
Boyko Markov
Telerik team
answered on 10 Apr 2009, 11:59 AM
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.
0
Craig Gamble
Top achievements
Rank 1
answered on 10 Apr 2009, 01:05 PM
cheers.

where can the RadElementCollection be found?

i have the following

using

 

Telerik.WinControls.UI;

 

using

 

Telerik.WinControls.UI.Scheduler;

 



0
Boyko Markov
Telerik team
answered on 13 Apr 2009, 12:38 PM
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.
0
Craig Gamble
Top achievements
Rank 1
answered on 15 Apr 2009, 08:30 AM

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;  
                    }  
                }  
            }  
 
0
Craig Gamble
Top achievements
Rank 1
answered on 15 Apr 2009, 08:50 AM
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?

0
Accepted
Boyko Markov
Telerik team
answered on 17 Apr 2009, 06:51 AM
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.
0
Craig Gamble
Top achievements
Rank 1
answered on 21 Apr 2009, 08:18 AM
cheers, that worked fine.
Tags
Scheduler and Reminder
Asked by
Craig Gamble
Top achievements
Rank 1
Answers by
Boyko Markov
Telerik team
Craig Gamble
Top achievements
Rank 1
Share this question
or