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

How to get selected time period

9 Answers 452 Views
Scheduler and Reminder
This is a migrated thread and some comments may be shown as answers.
Marcus
Top achievements
Rank 1
Marcus asked on 08 Jun 2009, 06:47 PM
Hi,
I have a RadScheduler that I've set up to drag and drop different tasks from a list box. Currently the task only fills one time slot (which is set at half-hour intervals) however I would like the user to be able to select a time period and drag the task to the selected area and have the "appointment" fill the entire selected area. 

I am having trouble retrieving the selected time period from the WinForms scheduler, is there a way to get the selected TimeSlot?

Thanks is advance,
Marcus

9 Answers, 1 is accepted

Sort by
0
Accepted
Boyko Markov
Telerik team
answered on 11 Jun 2009, 02:13 PM
Hello Marcus,

Thank you for contacting us. I have prepared a simple solution how to get the selection start and selection end dates.

1. Get the dayview element instance from RadScheduler.

  SchedulerDayViewElement dayview = (this.radSchedulerDemo.SchedulerElement.ViewElement as SchedulerDayViewElement);
2. Get the selection MinDate and selection MaxDate. I'm doing this by iterating over the cells collection. Then check whether a cell is selected and initialize the minDate and maxDate fields:

            DateTime minDate = DateTime.MaxValue;
            DateTime maxDate = DateTime.MinValue;

            foreach (RadElement element in dayview.DataAreaElement.Table.Children)
            {
                SchedulerCellElement cell = element as SchedulerCellElement;
                if (cell != null && cell.Selected)
                {
                    if (minDate >= cell.Date)
                    {
                        minDate = cell.Date;
                    }

                    if (maxDate <= cell.Date)
                    {
                        maxDate = cell.Date;
                    }
                }
            }

            TimeSpan selectionDuration = maxDate - minDate;

I hope this helps. Do not hesitate to write me back if you have further 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
Marcus
Top achievements
Rank 1
answered on 12 Jun 2009, 02:03 PM
Thanks! That almost got it, I just had to add time to the end of the max date (thirty minutes in my case) to find the time period from the beginning of the first cell to the end of the last cell.

Thanks for the help.
0
luca
Top achievements
Rank 2
answered on 02 Oct 2009, 07:26 AM
I had the same request and thank to that explanation i resolved! Thanks Boyko Markov for the perfect solution
0
Denis Cilliers
Top achievements
Rank 1
answered on 02 Oct 2012, 02:12 PM
Hi 
How would this be applied in VB.Net as the line 
dayview = TryCast(Me.radSchedulerDemo.SchedulerElement.ViewElement, SchedulerDayViewElement)

does not return anything for a selection event
0
Ivan Todorov
Telerik team
answered on 10 Oct 2012, 11:01 AM
Hi Denis,

This is the correct way to get the SchedulerDayViewElement, however you can get it only if RadScheduler is currently under DayView. Otherwise the ViewElement will be of different type and the TryCast will return Nothing.

If your goal is to get the selected dates, then you can use the following method to achieve this without having to cast any elements:
Dim dates As DateTime() = SchedulerUIHelper.GetSelectedDates(Me.RadScheduler1)
Array.Sort(dates)
Dim interval As New DateTimeInterval(dates(0), dates(dates.Length - 1))

If your requirement is different, then please share more details on it and I will assist you in achieving it.

Should you have any other questions, feel free to ask.

Kind regards,
Ivan Todorov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Gerhard
Top achievements
Rank 1
answered on 03 Dec 2012, 11:25 AM
How do I do this in VB.net. It loops through the 72 cells but everyone seems is selected = false.
0
Ivan Todorov
Telerik team
answered on 06 Dec 2012, 09:12 AM
Hello Gerhard,

The approach should be the same in C# and VB. However, you can try using one of the following methods of the SchedulerUIHelper class:
SchedulerUIHelper.GetCells(Me.RadScheduler1)
SchedulerUIHelper.GetSelectedCells(Me.RadScheduler1)
SchedulerUIHelper.GetSelectedDates(Me.RadScheduler1)

If you have any additional questions, please let me know.

Greetings,
Ivan Todorov
the Telerik team
Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
0
Chandz
Top achievements
Rank 2
answered on 03 Feb 2016, 02:25 PM
Hello Telerik team,

 I have a Radscheduler and an individual button, in a web form in my aspx page(c# and Asp.net).

when in week view of the scheduler, it displays the first week (i.e)  jan 3 2016 sunday to jan 9 2016 saturday,

i want to view the next week on button click (i.e)  jan 10 2016 sunday to jan 16 2016 saturday,

telerik has dayview, weekview, monthview, agendaview and timelineview but not nextweekview..

Googling does not help me in this case.

 

Thanks in advance..

Hope you people reply a bit faster.
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 03 Feb 2016, 03:40 PM

Hello ,

Thank you for writing.

I would like to note that this forum is related to the Telerik UI for WinForms suite. However, your question seems to be connected with the ASP.NET product. Feel free to post your question in the relevant forum: http://www.telerik.com/forums

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

Regards,
Dess
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Scheduler and Reminder
Asked by
Marcus
Top achievements
Rank 1
Answers by
Boyko Markov
Telerik team
Marcus
Top achievements
Rank 1
luca
Top achievements
Rank 2
Denis Cilliers
Top achievements
Rank 1
Ivan Todorov
Telerik team
Gerhard
Top achievements
Rank 1
Chandz
Top achievements
Rank 2
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or