Customizing the Timeline View

5 posts, 1 answers
  1. Adam
    Adam avatar
    1 posts
    Member since:
    Nov 2010

    Posted 10 Nov 2010 Link to this post

    I am looking to use the Timeline View with Resource Grouping to show a timeline of about three months, (from 2-weeks-ago to 2-months-from-now), all visible at once, and allow for scrolling beyond those visible limits.

    It seems that, by default, the timeline shows only 7 days ahead of the StartDate which I have set to DateTime.Now.AddDays(-14) to set the first visible date back two weeks from today.  I would like to be able to set the number of visible days to ±70, (and eventually use a radtrackBar to dynamically change the number of visible days).

    Aside from that, how would I set the width of the day 'columns' in the TimeLine?  Most of the appointments I will be adding to the scheduler will be several days, even weeks in duration and I will only require a month heading and a numerical day label.

    Thanks,
    Adam

  2. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 11 Nov 2010 Link to this post

    Hi Adam,

    In order to change the number of visible days in the TimelineView isn't straightforward. This is controlled via the CurrentScale property of the TimeLineView which is, in this case a DayTimeScale. However, the CurrentScale property does not have a setter.

    I have managed with the code below to change the value and it is reflected in the RadScheduler, but it only displays correctly after using the scrollbar to scroll the next section into view.

    I will continue to have a look at a way to do this for you, but in the meantime, I thought this code may help you to get started.

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.RadScheduler1.SchedulerElement.BeginElementUpdate()
        Dim timelineView As SchedulerTimelineView = Me.RadScheduler1.GetTimelineView()
        Dim dayScale As New DaytimeScale()
        dayScale.DisplayedCellsCount = 20
        Dim currentScaleProperty As PropertyInfo
        For Each p As PropertyInfo In GetType(Telerik.WinControls.UI.SchedulerTimelineView).GetProperties()
            If p.Name = "CurrentScale" Then
                currentScaleProperty = p
                Exit For
            End If
        Next
        currentScaleProperty.SetValue(timelineView, dayScale, Nothing)
        Me.RadScheduler1.SchedulerElement.EndElementUpdate()
    End Sub

    Perhaps there is an easier way. I will let you know as soon as possible.

    Hope this helps
    Richard
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 11 Nov 2010 Link to this post

    Hi Adam,

    Ok, I have this working. I just changed the StartDate and that seems to cause teh required refresh. the final code has a navigator and can be seen in the screenshot attached.

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.RadScheduler1.ActiveViewType = SchedulerViewType.Timeline
        Me.RadScheduler1.SchedulerElement.BeginElementUpdate()
        Dim timelineView As SchedulerTimelineView = Me.RadScheduler1.GetTimelineView()
        Dim dayScale As New DaytimeScale()
        dayScale.DisplayedCellsCount = 20
        Dim currentScaleProperty As PropertyInfo
        For Each p As PropertyInfo In GetType(Telerik.WinControls.UI.SchedulerTimelineView).GetProperties()
            If p.Name = "CurrentScale" Then
                currentScaleProperty = p
                Exit For
            End If
        Next
        currentScaleProperty.SetValue(timelineView, dayScale, Nothing)
        Me.RadScheduler1.SchedulerElement.EndElementUpdate()
        Me.RadSchedulerNavigator1.MonthViewButtonVisible = False
        Me.RadSchedulerNavigator1.WeekViewButtonVisible = False
        Me.RadSchedulerNavigator1.DayViewButtonVisible = False
        Me.RadSchedulerNavigator1.AssociatedScheduler = Me.RadScheduler1
        timelineView.StartDate = DateTime.Now.AddDays(1)
        timelineView.StartDate = DateTime.Now
    End Sub

    Hope this helps, but if you have any more questions, just let me know.
    Richard
  5. Dobry Zranchev
    Admin
    Dobry Zranchev avatar
    348 posts

    Posted 17 Nov 2010 Link to this post

    Hi Adam,

    You could update the number of displayed slots in the timeline view as it is shown below: 
    this.radScheduler1.GroupType = GroupType.None;
    this
    .radScheduler1.GetTimelineView().GetTimescale(Timescales.Days).DisplayedCellsCount = 70;
    this.radScheduler1.GroupType = GroupType.Resource;

    If you have other questions, feel free to write us back.

    Kind regards,
    Dobry Zranchev
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  6. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 17 Nov 2010 Link to this post

    Hi Dobry,

    It's that simple. I've learnt something new too. Thanks!
    Richard
Back to Top
UI for WinForms is Visual Studio 2017 Ready