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

Limit ScheduleView to a date range

2 Answers 160 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Stuart Cotts
Top achievements
Rank 1
Stuart Cotts asked on 15 Mar 2013, 03:09 PM
I'm probably just missing this somewhere.

I would like ScheduleView to stay within a range of dates, not allow the user to view dates before a given date or after a given date, I.E. not allow a week view to go before 3/10/2013 or after 3/24/2013.

What would be the easiest way to accomplish this?

Thanks!

2 Answers, 1 is accepted

Sort by
0
Neelima
Top achievements
Rank 1
answered on 15 Mar 2013, 09:03 PM
Sorry to piggy back on this.

I need the same functionality.
0
Yana
Telerik team
answered on 21 Mar 2013, 10:01 AM
Hello there,

RadScheduleView does not provide a built-in functionality for setting min and max dates. However, you could subscribe to VisibleRangeChanged event and set the CurrentDate if the new range is out of the predefined min and max dates. Here is a sample code snippet:

private void ScheduleView_VisibleRangeChanged(object sender, EventArgs e)
{
    var minDate = new DateTime(2013,3,10,0,0,0);
    var maxDate = new DateTime(2013,4,10, 0, 0,0);
 
    var scheduleView = sender as RadScheduleView;
    var visibleRange = scheduleView.VisibleRange;
    if (visibleRange.Start < minDate)
    {
        scheduleView.CurrentDate = minDate;            
    }
    else if (visibleRange.End > maxDate)
    {
        scheduleView.CurrentDate = maxDate;
    }      
}  

I hope this helps.

Kind regards,
Yana
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
ScheduleView
Asked by
Stuart Cotts
Top achievements
Rank 1
Answers by
Neelima
Top achievements
Rank 1
Yana
Telerik team
Share this question
or