The onResourceExpand callback runs after an individual resource tree group is expanded. It is available in Lite since version 2026.4.899 and in Pro.

Expand the Design team using its row-header arrow. The callback receives the expanded 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.

Loading children on demand is a separate Pro dynamic-loading feature; this notification also works with Lite's fully supplied resource hierarchy.

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: false, 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"}],
  onResourceExpand: args => {
      console.log("Expanded 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: false, 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"}],
    onResourceExpand: args => {
      console.log("Expanded 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: false, 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"}]}
    onResourceExpand={args => {
      console.log("Expanded 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: false, 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 onResourceExpand = (args: DayPilot.SchedulerResourceExpandArgs) => {
  console.log("Expanded 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"
    :onResourceExpand="onResourceExpand"
  />
</template>

See also

ASP.NET WebForms

ResourceExpand event is called after a resource tree node is expanded by the user.

The event handling type can be set using ResourceExpandHandling property:

  • Disabled (the event will not be fired)
  • CallBack (ResourceExpand server-side event is called using a CallBack)
  • PostBack (ResourceExpand server-side event is called using a PostBack)
  • JavaScript (the event is handled on the client side using ResourceExpandJavaScript)

Note: If you want to load the resource child nodes dynamically, you should set Resource.ChildrenLoaded = false and handle LoadNode event. See also Dynamic resource tree loading.

Example

ResourceExpandHandling="JavaScript"
ResourceExpandJavaScript="alert('Resource ' + resource.name + ' expanded.');"

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