The onResourceCollapse event handler fires in the JavaScript Scheduler after a resource tree node collapses.
Available in DayPilot Lite for JavaScript since version 2026.4.899.
Declaration
DayPilot.Scheduler.onResourceCollapse(args)Parameters
args.resource(DayPilot.Row) - collapsed resource rowargs.preventDefault()- prevents the action specified by resourceCollapseHandling, but does not stop the node from collapsing
Lite Behavior
The callback runs after an individual node changes state, including changes made using the corresponding DayPilot.Row method. The updated row is available as args.resource. Calling args.preventDefault() does not undo the completed collapse; Lite does not perform a server callback or postback.
Bulk tree methods do not guarantee one notification per changed row. Handle the overall bulk action separately when your application needs to react to all changes.
Pro and Legacy Server Integration
Calling args.preventDefault() doesn't prevent the node from collapsing. It only prevents the action specified by resourceCollapseHandling, such as "PostBack" or "CallBack".
In api=1 mode, the legacy signature is onResourceCollapse(resource), where resource is a DayPilot.Resource object with the following properties:
start(DayPilot.Date) - resource start (corresponds tostartDatewhenviewType == "Resource")name(string) - resource namevalue(string) - resource ID
Examples
These snippets attach a notification to an existing resource tree. Keep the existing resources and timeline options.
JavaScript
const dp = new DayPilot.Scheduler("dp", {
treeEnabled: true,
onResourceCollapse: (args) => {
console.log("Collapsed resource", args.resource);
},
// ...
});
dp.init();Angular
<daypilot-scheduler [config]="config"></daypilot-scheduler>config: DayPilot.SchedulerConfig = {
treeEnabled: true,
onResourceCollapse: (args) => {
console.log("Collapsed resource", args.resource);
},
// ...
};React
<DayPilotScheduler
treeEnabled={true}
onResourceCollapse={onResourceCollapse}
/>const onResourceCollapse = (args) => {
console.log("Collapsed resource", args.resource);
};Vue
<DayPilotScheduler
:treeEnabled="true"
:onResourceCollapse="onResourceCollapse"
/>const onResourceCollapse = (args) => {
console.log("Collapsed resource", args.resource);
};See Also
Resource Collapse Event [doc.daypilot.org]
DayPilot.Scheduler.resourceCollapseHandling
Availability
Availability of this API item in DayPilot editions:
| Product | Lite | Pro |
|---|---|---|
| DayPilot for JavaScript |
DayPilot