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

Timeline view - show weekend with different backgroud colour?

7 Answers 177 Views
Scheduler and Reminder
This is a migrated thread and some comments may be shown as answers.
MattL
Top achievements
Rank 1
MattL asked on 22 Jul 2011, 03:29 PM
Is this possible?

Thanks

7 Answers, 1 is accepted

Sort by
0
Accepted
Ivan Todorov
Telerik team
answered on 27 Jul 2011, 08:22 AM
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!

0
MattL
Top achievements
Rank 1
answered on 27 Jul 2011, 05:26 PM

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
0
Ivan Todorov
Telerik team
answered on 01 Aug 2011, 11:35 AM
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!

0
Norkitt
Top achievements
Rank 1
answered on 12 Oct 2011, 08:34 PM
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.
0
Ivan Todorov
Telerik team
answered on 14 Oct 2011, 09:45 AM
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.

0
Rasmus
Top achievements
Rank 1
answered on 04 May 2016, 08:07 AM

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

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 05 May 2016, 11:56 AM
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.
Tags
Scheduler and Reminder
Asked by
MattL
Top achievements
Rank 1
Answers by
Ivan Todorov
Telerik team
MattL
Top achievements
Rank 1
Norkitt
Top achievements
Rank 1
Rasmus
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or