html5-scheduler-hiding-non-business-hours.png

It is possible to hide cells outside of business hours (specified using BusinessBeginsHour and BusinessEndsHour) using ShowNonBusiness property.

You can also hide selected time columns or generate a custom timeline.

JavaScript

javascript-scheduler-hiding-weekends.png

See also DayPilot.Scheduler.onIncludeTimeCell and hiding time columns.

Hiding the predefined non-business hours:

<div id="dp"></div>

<script>
  var dp = new DayPilot.Scheduler("dp");
  dp.businessBeginsHour = 9;
  dp.businessEndsHour = 18;
  dp.showNonBusiness = false;
  // ...
  dp.init();

</script>

Column hiding customization:

<div id="dp"></div>
<script type="text/javascript">
  var dp = new DayPilot.Scheduler("dp");
  dp.onIncludeTimeCell = function(args) {
    if (args.cell.start.getDayOfWeek() === 0 || args.cell.start.getDayOfWeek() === 6) { // hide Saturdays, Sundays
      args.cell.visible = false;
    }
  };
  // ...
  dp.init();
</script>

Demo

Tutorial

ASP.NET WebForms

You can turn this feature on just by setting:

  • ShowNonBusiness="false"

This setup will hide:

  • Weekends (Saturday and Sunday)
  • Hours before BusinessBeginsHour (default value is 9) and after BusinessEndsHour (default 18)

DayPilot Scheduler: Showing Workdays Only

asp.net-scheduler-hiding-weekends.png

.aspx

<DayPilot:DayPilotScheduler
  ... Scale="Day"
  ShowNonBusiness="false"
/>

DayPilot Scheduler: Showing 9AM - 5PM (+Lunch Break 12PM - 1PM)

asp.net-scheduler-hiding-non-business-hours-custom.png

.aspx

<DayPilot:DayPilotScheduler
  ...
  BusinessBeginsHour="9"
  BusinessEndsHour="18"
  ShowNonBusiness="false" OnIncludeCell="DayPilotScheduler1_IncludeCell"
/>

.aspx.cs

protected void DayPilotScheduler1_IncludeCell(object sender, IncludeCellEventArgs e)
{
  if (e.Start.Hour == 12)
  {
      e.Visible = false;
  }
}

DayPilot Scheduler: Showing 9AM - 5PM (Lunch Break Highlighted)

asp.net-scheduler-hiding-non-business-hours-lunch-break.png

Column hiding can be combined with cell highlighting. The lunch break can be highlighted instead using BeforeCellRender event handler.

.aspx

<DayPilot:DayPilotScheduler
  ...
  BusinessBeginsHour="9"
  BusinessEndsHour="18"
  ShowNonBusiness="false" OnBeforeCellRender="DayPilotScheduler1_BeforeCellRender"
/>

.aspx.cs

protected void DayPilotScheduler1_BeforeCellRender(object sender, DayPilot.Web.Ui.Events.BeforeCellRenderEventArgs e)
{
  if (e.Start.Hour == 12)
  {
    e.IsBusiness = false;
  }
}

Note that setting IsBusiness property in BeforeCellRender will not hide the column, but rather use the color specified for non-business hours (NonBusinessBackColor) for that cell.

ASP.NET MVC

scheduler-for-asp.net-mvc-hiding-weekends.png

It is possible to hide the non-business hours by setting ShowNonBusiness = false.

In this mode, weekends and all time columns defined as non-business using the BusinessBeginsHour and BusinessEndsHour range will be hidden.

See also hiding time columns.