viewOptions
Options a family of views takes beyond the calendar’s own, keyed by family.
| Type | Readonly<Record<string, unknown>> |
|---|---|
| Default | not set |
Live update (update()) | Yes |
| Declared in | packages/dom/src/calendar.ts |
What it does
Section titled “What it does”A family that is not built in — the Pro’s timeline, a view of your own
made with defineView — reads its settings from here, under its family’s
name. Today the Pro’s timeline reads viewOptions.timeline.areaColumns: the
resource area’s columns, each { field, header?, width? } (field read from
the resource, then what you gave, then extendedProps; width in pixels,
160 for the first and 110 for the others by default).
update({ viewOptions }) redraws a family whose object is replaced — compared by reference, family by family: keep the object stable. The title column’s head is messages.resource’s words unless header says otherwise.
Example
Section titled “Example”import { createCalendar } from '@dzcalendar/dom';import '@dzcalendar/pro';
createCalendar(element, { timeZone: 'Europe/Paris', initialView: 'resourceTimelineDay', resources: [{ id: 'benali', title: 'Dr Benali', room: 'A12' }, { id: 'haddad', title: 'Dr Haddad', room: 'B03' }], viewOptions: { timeline: { areaColumns: [{ field: 'title', header: 'Doctor', width: 170 }, { field: 'room', header: 'Room' }] } },});import { Component } from '@angular/core';import { DZ_CALENDAR } from '@dzcalendar/angular';import '@dzcalendar/pro';
@Component({ selector: 'app-planning', imports: [DZ_CALENDAR], template: `<dz-calendar timeZone="Europe/Paris" view="resourceTimelineDay" [resources]="staff" [options]="{ viewOptions: { timeline: { areaColumns: [{ field: 'title', header: 'Doctor' }, { field: 'room', header: 'Room' }] } } }" />`,})export class Planning { readonly staff = [{ id: 'benali', title: 'Dr Benali', room: 'A12' }];}import { DzCalendar } from '@dzcalendar/react';import '@dzcalendar/pro';
const STAFF = [{ id: 'benali', title: 'Dr Benali', room: 'A12' }];const COLUMNS = { timeline: { areaColumns: [{ field: 'title', header: 'Doctor' }, { field: 'room', header: 'Room' }] } };
export function Planning() { return <DzCalendar timeZone="Europe/Paris" defaultView="resourceTimelineDay" resources={STAFF} viewOptions={COLUMNS} />;}<script setup lang="ts">import { DzCalendar } from '@dzcalendar/vue';import '@dzcalendar/pro';
const staff = [{ id: 'benali', title: 'Dr Benali', room: 'A12' }];const columns = { timeline: { areaColumns: [{ field: 'title', header: 'Doctor' }, { field: 'room', header: 'Room' }] } };</script>
<template> <DzCalendar time-zone="Europe/Paris" view="resourceTimelineDay" :resources="staff" :options="{ viewOptions: columns }" /></template>In Angular and Vue it goes in options; in React it is a prop.
Live demo
Section titled “Live demo”The timeline’s resource area shows each resource’s title and room.
See also
Section titled “See also”timeline— the timeline’s scale and lanes.resources— the fields the columns read.- Resources & timeline.