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

Timeline View - Set First Date

2 Answers 78 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Kieron
Top achievements
Rank 1
Kieron asked on 03 Jun 2016, 07:51 AM

Hi,

Is it possible to use the timeline layout for 7 days but setting the first date shown to be the first day of the week.  If I switch from Day view to Timeline view, the first day shown in the Timeline is always the day you were looking at in Day View whereas I would like it to be the first day of that week - Monday.

I would use Week View but when I put it into Horizontal orientation to try and emulate the Timeline layout, the date part of the TimeRuler sits on the Y axis (along with each Resource) and this stretches out each Resource bigger than I would like - ideally I want the dates to stay with the times on the TimeRuler.

 

Thanks.

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Yana
Telerik team
answered on 06 Jun 2016, 10:52 AM
Hi Kieron,

Indeed, TimelineViewDefinition starts from the CurrentDate while WeekViewDefinition starts from the first day of the week containing CurrentDate.  You could check How to configure the VisibleRange topic for more details on the different ViewDefinitions.

You could achieve the required approach by subscribing to VisibleRangeChanged event of the ScheduleView and update the CurrentDate in its handler. Here is a quick example:

<telerik:RadScheduleView x:Name="radScheduleView"
            AppointmentsSource="{Binding Appointments}" FirstDayOfWeek="Sunday"
            VisibleRangeChanged="radScheduleView_VisibleRangeChanged">
    <telerik:RadScheduleView.ViewDefinitions>
        <telerik:WeekViewDefinition/>
        <telerik:TimelineViewDefinition  />                     
    </telerik:RadScheduleView.ViewDefinitions>
</telerik:RadScheduleView>

private void radScheduleView_VisibleRangeChanged(object sender, EventArgs e)
{
    var scheduleView = sender as RadScheduleView;
    if (scheduleView.ActiveViewDefinition is TimelineViewDefinition)
    {
        scheduleView.CurrentDate = GetFirstDateOfWeek(scheduleView.CurrentDate, DayOfWeek.Sunday);
    }
}
 
public  DateTime GetFirstDateOfWeek(DateTime dayInWeek, DayOfWeek firstDay)
{
    DateTime firstDayInWeek = dayInWeek.Date;
    while (firstDayInWeek.DayOfWeek != firstDay)
        firstDayInWeek = firstDayInWeek.AddDays(-1);
    return firstDayInWeek;
}

I hope this would be helpful.

Regards,
Yana
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Kieron
Top achievements
Rank 1
answered on 07 Jun 2016, 01:48 PM
Thanks, it solves the problem
Tags
ScheduleView
Asked by
Kieron
Top achievements
Rank 1
Answers by
Yana
Telerik team
Kieron
Top achievements
Rank 1
Share this question
or