Timeline view - show weekend with different backgroud colour?

8 posts, 1 answers
  1. MattL
    MattL avatar
    7 posts
    Member since:
    May 2007

    Posted 22 Jul 2011 Link to this post

    Is this possible?

    Thanks
  2. Answer
    Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 27 Jul 2011 Link to this post

    Hi Mattl,

    Thank you for your question.

    You can achieve this by creating and using a descendant class of RadScheduler. The following code snippet demonstrates how you can achieve this:
    public class MyScheduler : RadScheduler
    {
        public override void InvalidateElement(Telerik.WinControls.RadElement element)
        {
            if (this.ActiveViewType != SchedulerViewType.Timeline)
            {
                base.InvalidateElement(element);
                return;
            }
     
            foreach (RadElement child in (this.SchedulerElement.ViewElement as SchedulerTimelineViewElement).Presenter.Children)
            {
                SchedulerCellElement cell = (child as SchedulerCellElement);
                if (cell != null)
                {
                    if (cell.Date.DayOfWeek == DayOfWeek.Sunday || cell.Date.DayOfWeek == DayOfWeek.Saturday)
                    {
                        cell.BackColor = Color.Red;
                    }
                    else
                    {
                        cell.ResetValue(RadItem.BackColorProperty, ValueResetFlags.Local);
                    }
                }
            }
     
            base.InvalidateElement(element);
        }
     
        public override string ThemeClassName
        {
            get
            {
                return typeof(RadScheduler).FullName;
            }
            set
            {
                base.ThemeClassName = value;
            }
        }
    }

    I hope this is helpful. Feel free to ask if you have any additional questions.

    Regards,
    Ivan Todorov
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. UI for WinForms is Visual Studio 2017 Ready
  4. MattL
    MattL avatar
    7 posts
    Member since:
    May 2007

    Posted 27 Jul 2011 Link to this post

    That works nicely.

    I have updated my form with the inherited version of the control by updating the designer.vb file but is there a way I can do this in code in a similar way the drag & drop example assigns the MyGridBehavior class to

    NameOfGrid.GridBehavior = New MyGridBehavior()

    Thanks
  5. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 01 Aug 2011 Link to this post

    Hello Mattl,

    This is not possible in this case, because you are inheriting directly from the main RadScheduler control and not from a part of it.

    Do not hesitate to ask if you have any further questions.

    All the best,
    Ivan Todorov
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  6. Norkitt
    Norkitt avatar
    2 posts
    Member since:
    Oct 2011

    Posted 12 Oct 2011 Link to this post

    Hello I used the code snippet provided above but when I try to change the view type to timeline I get a NullReferenceException exception. Why is this happening?
    Thanks.
  7. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 14 Oct 2011 Link to this post

    Hello Norkitt,

    Thank you for writing.

    This is happening, because when you switch between views, the ActiveViewType property is changed, but some of the elements are initialized yet. I have updated the previously posted code, so that the exception does not occur. Below is the modified sample:
    public override void InvalidateElement(Telerik.WinControls.RadElement element)
     {
         if (this.ActiveViewType != SchedulerViewType.Timeline)
         {
             base.InvalidateElement(element);
             return;
         }
     
         SchedulerTimelineViewElement timelineElement = this.SchedulerElement.ViewElement as SchedulerTimelineViewElement;
         if (timelineElement == null || timelineElement.Presenter==null)
         {
             return;
         }
     
         foreach (RadElement child in timelineElement.Presenter.Children)
         {
             SchedulerCellElement cell = (child as SchedulerCellElement);
             if (cell != null)
             {
                 if (cell.Date.DayOfWeek == DayOfWeek.Sunday || cell.Date.DayOfWeek == DayOfWeek.Saturday)
                 {
                     cell.BackColor = Color.Red;
                 }
                 else
                 {
                     cell.ResetValue(RadItem.BackColorProperty, ValueResetFlags.Local);
                 }
             }
         }
    }

    I hope you find this useful. Do not hesitate to ask in case you have any additional questions.

    Best wishes,
    Ivan Todorov
    the Telerik team

    Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

  8. Rasmus
    Rasmus avatar
    2 posts
    Member since:
    Nov 2015

    Posted 04 May Link to this post

    http://demos.telerik.com/kendo-ui/scheduler/timeline

    In this example, the weekends have their color in red, to show its weekends.
    How do one set this in the kendo scheduler?

    Regards
    Rasmus

  9. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 05 May Link to this post

    Hello Rasmus,

    Thank you for writing.

    Note that this forum is related to the Telerik UI for WinForms product. If you have any questions regarding Kendo UI, feel free to post 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 need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top
UI for WinForms is Visual Studio 2017 Ready