The onResourceCollapse callback runs after an individual resource tree group is collapsed. It is available in Lite since version 2026.4.899 and in Pro.
Collapse the Design team using its row-header arrow. The callback receives the collapsed row as args.resource. Use its ID or name to update application state, record the user's choice, or refresh related details.
The change has already happened when this callback runs. args.preventDefault() does not undo the local toggle. Do not use this notification as a before-toggle veto, and do not depend on one callback per row when using bulk expand/collapse operations.
The examples use Lite packages. The same static tree options work in Pro; keep your Pro package imports if your application uses Pro. For component setup, see the Angular, React, and Vue integration guides.
JavaScript
Create a dp container and load DayPilot before running this example:
const scheduler = new DayPilot.Scheduler("dp", {
startDate: "2028-04-03",
days: 14,
scale: "Day",
timeHeaders: [{groupBy: "Month"}, {groupBy: "Day", format: "d"}],
treeEnabled: true,
rowHeaderWidth: 200,
resources: [{id: "design", name: "Design team", expanded: true, children: [
{id: "alex", name: "Alex Morgan"},
{id: "casey", name: "Casey Brooks"}
]}],
events: [{id: 1, resource: "alex", text: "Interface design",
start: "2028-04-05", end: "2028-04-08"}],
onResourceCollapse: args => {
console.log("Collapsed resource:", args.resource.id);
}
});
scheduler.init();
Angular
import {Component} from "@angular/core";
import {DayPilot, DayPilotModule} from "@daypilot/daypilot-lite-angular";
@Component({
selector: "app-tree-example",
standalone: true,
imports: [DayPilotModule],
template: `<daypilot-scheduler [config]="config"></daypilot-scheduler>`
})
export class TreeExampleComponent {
config: DayPilot.SchedulerConfig = {
startDate: "2028-04-03",
days: 14,
scale: "Day",
timeHeaders: [{groupBy: "Month"}, {groupBy: "Day", format: "d"}],
treeEnabled: true,
rowHeaderWidth: 200,
resources: [{id: "design", name: "Design team", expanded: true, children: [
{id: "alex", name: "Alex Morgan"},
{id: "casey", name: "Casey Brooks"}
]}],
events: [{id: 1, resource: "alex", text: "Interface design",
start: "2028-04-05", end: "2028-04-08"}],
onResourceCollapse: args => {
console.log("Collapsed resource:", args.resource.id);
}
};
}
React
import React from "react";
import {DayPilotScheduler} from "@daypilot/daypilot-lite-react";
export default function TreeExample() {
return <DayPilotScheduler
startDate="2028-04-03"
days={14}
scale="Day"
timeHeaders={[{groupBy: "Month"}, {groupBy: "Day", format: "d"}]}
treeEnabled={true}
rowHeaderWidth={200}
resources={[{id: "design", name: "Design team", expanded: true, children: [
{id: "alex", name: "Alex Morgan"},
{id: "casey", name: "Casey Brooks"}
]}]}
events={[{id: 1, resource: "alex", text: "Interface design",
start: "2028-04-05", end: "2028-04-08"}]}
onResourceCollapse={args => {
console.log("Collapsed resource:", args.resource.id);
}}
/>;
}
Vue
<script setup lang="ts">
import {DayPilot, DayPilotScheduler} from "@daypilot/daypilot-lite-vue";
const resources = [{id: "design", name: "Design team", expanded: true, children: [
{id: "alex", name: "Alex Morgan"},
{id: "casey", name: "Casey Brooks"}
]}];
const events = [{id: 1, resource: "alex", text: "Interface design",
start: "2028-04-05", end: "2028-04-08"}];
const onResourceCollapse = (args: DayPilot.SchedulerResourceCollapseArgs) => {
console.log("Collapsed resource:", args.resource.id);
};
</script>
<template>
<DayPilotScheduler
startDate="2028-04-03"
:days="14"
scale="Day"
:timeHeaders="[{groupBy: 'Month'}, {groupBy: 'Day', format: 'd'}]"
:treeEnabled="true"
:rowHeaderWidth="200"
:resources="resources"
:events="events"
:onResourceCollapse="onResourceCollapse"
/>
</template>
See also
- DayPilot.Scheduler.onResourceCollapse (client-side API)
ASP.NET WebForms
ResourceCollapse event is called after a resource tree node is collapsed by the user.
The event handling type can be set using ResourceCollapseHandling property:
- Disabled (the event will not be fired)
- CallBack (ResourceCollapse server-side event is called using a CallBack)
- PostBack (ResourceCollapse server-side event is called using a PostBack)
- JavaScript (the event is handled on the client side using ResourceCollapseJavaScript)
Example
ResourceCollapseHandling="JavaScript"
ResourceCollapseJavaScript="alert('Resource ' + resource.name + ' collapsed.');"Availability
Availability of this feature in DayPilot editions:
| Product | Lite | Pro |
|---|---|---|
| DayPilot for JavaScript | ||
| DayPilot for ASP.NET WebForms | ||
| DayPilot for ASP.NET MVC | ||
| DayPilot for Java |
DayPilot