Skip to content

onResourceToggle

Hears a person fold or unfold a resource or a group in the Pro’s timeline.

Type(state: { readonly collapsedResources: readonly string[]; readonly collapsedGroups: readonly string[] }) => void
Defaultnot set
Live update (update())Yes
Declared inpackages/dom/src/settings.ts

It receives the whole state after the change — { collapsedResources, collapsedGroups } — not the one row toggled: store it as it comes, and give it back as collapsedResources and collapsedGroups the next time, so the timeline opens as the person left it. A change made by your code (update({ collapsedResources })) is not reported.

import { createCalendar } from '@dzcalendar/dom';
import '@dzcalendar/pro';
const saved = JSON.parse(localStorage.getItem('tree') ?? '{}') as { collapsedResources?: string[]; collapsedGroups?: string[] };
createCalendar(element, {
timeZone: 'Europe/Paris',
initialView: 'resourceTimelineWeek',
resources: [{ id: 'cardio', title: 'Cardiology' }, { id: 'benali', title: 'Dr Benali', parentId: 'cardio' }],
...saved,
onResourceToggle: (state) => localStorage.setItem('tree', JSON.stringify(state)),
});

In Angular and Vue it goes in options; in React it is a prop.