javascript calendar time header cell customization

Use onBeforeTimeHeaderRender to customize the default time headers. This example formats the time using args.header.time and applies the hourheader CSS class. It works without configuring grouped headers.

Set args.header.html for displayed content and args.header.text for its plain-text image-export label. The examples configure an existing Calendar; retain its other settings.

For multiple header levels and level-specific styling, see Grouped Time Headers.

JavaScript

const calendar = new DayPilot.Calendar("dp", {
  onBeforeTimeHeaderRender: args => {
    const time = DayPilot.Date.today().addTime(args.header.time);
    const label = time.toString("h:mm tt");
    args.header.html = label;
    args.header.text = label;
    args.header.cssClass = "hourheader";
  }
});
calendar.init();

Angular

<daypilot-calendar [config]="config"></daypilot-calendar>
import {DayPilot} from "daypilot-pro-angular";

config: DayPilot.CalendarConfig = {
  onBeforeTimeHeaderRender: args => {
    const time = DayPilot.Date.today().addTime(args.header.time);
    const label = time.toString("h:mm tt");
    args.header.html = label;
    args.header.text = label;
    args.header.cssClass = "hourheader";
  }
};

React

import {DayPilot, DayPilotCalendar} from "daypilot-pro-react";

<DayPilotCalendar
  onBeforeTimeHeaderRender={args => {
    const time = DayPilot.Date.today().addTime(args.header.time);
    const label = time.toString("h:mm tt");
    args.header.html = label;
    args.header.text = label;
    args.header.cssClass = "hourheader";
  }}
/>

Vue

<script setup lang="ts">
import {DayPilot, DayPilotCalendar} from "daypilot-pro-vue";
const onBeforeTimeHeaderRender: NonNullable<DayPilot.CalendarConfig["onBeforeTimeHeaderRender"]> = args => {
    const time = DayPilot.Date.today().addTime(args.header.time);
    const label = time.toString("h:mm tt");
    args.header.html = label;
    args.header.text = label;
    args.header.cssClass = "hourheader";
  };
</script>

<template>
  <DayPilotCalendar
    :onBeforeTimeHeaderRender="onBeforeTimeHeaderRender"
  />
</template>

CSS

Add the CSS class to your stylesheet. This selector uses the default Calendar theme.

.hourheader .calendar_default_rowheader_inner {
  color: #33465c;
}

ASP.NET WebForms

Read-only properties:

  • Start

  • End

  • Hour

Customizable properties:

protected void DayPilotCalendar1_BeforeTimeHeaderRender(DayPilot.Web.Ui.Events.Calendar.BeforeTimeHeaderRenderEventArgs e)
{
  e.Html = e.Start.ToString("HH:mm");
}

ASP.NET MVC

Read-only properties:

  • Start

  • Hour

Customizable properties:

  • Html

protected override void OnBeforeTimeHeaderRender(BeforeTimeHeaderRenderArgs e)
{
  e.Html = e.Start.ToString("HH:mm");
}

Availability

Availability of this feature in DayPilot editions:

ProductLitePro
DayPilot for JavaScript
DayPilot for ASP.NET WebForms
DayPilot for ASP.NET MVC
DayPilot for Java