DayPilot Knowledge Base

AJAX Calendar/Scheduling Controls
DayPilot Pro (AJAX Calendar Control)
» DayPilot AJAX Calendar
DayPilot Pro (AJAX Monthly Calendar Control)
» DayPilot AJAX Monthly Calendar
DayPilot Pro (AJAX Scheduler Control)
» DayPilot AJAX Scheduler
DayPilot » Knowledge Base » How to show business hours on weekends in Scheduler

How to show business hours on weekends in Scheduler

Last revision: Mar 2, 2010

It is possible to hide non-business hours using ShowNonBusiness property (ShowNonBusiness="false") in the Scheduler.

This is the default business hours definition:

Customization

It is possible to show/hide individual time slots per column (but not per cell) using BeforeTimeHeaderRender event handler:

Example

    protected void DayPilotScheduler1_BeforeTimeHeaderRender(object sender, DayPilot.Web.Ui.Events.BeforeTimeHeaderRenderEventArgs e)
        if (!e.IsColGroup && (e.Start.DayOfWeek == DaysOfWeek.Saturday || e.Start.DayOfWeek == DaysOfWeek.Sunday))
        {
            if (DayPilotScheduler1.CellDuration < 60 * 24) { // use business hours for one cell < one day resolution
                if (end.TimeOfDay.TotalHours <= BusinessBeginsHour)
                {
                    e.Visible = false;
                }
                else if (start.TimeOfDay.TotalHours >= BusinessEndsHour)
                {
                    e.Visible = false;
                }
                else {
                    e.Visible = true;
                }
            }
            else if (DayPilotScheduler1.CellDuration == 60 * 24) {  // always show it when one cell == one day
              e.Visible = true;
            }
        }     
    }

Time cell colors based on IsBusiness

If ShowNonBusiness is set to true, the non-business time cells are highlighted using a different background color:

This behavior can be customized per cell using BeforeCellRender event handler (e.IsBusiness property). It is also possible to specify the color directly (e.BackgroundColor).

Related

How to combine column visibility and cell background to show business hours in the Scheduler
How To Set Up Overnight Shift Scheduling with DayPilot Calendar
How to define Calendar business and non-business days
What is the duration of one week in minutes?