DayPilot.Scheduler.onLoadNode

The onLoadNode event is fired by the JavaScript Scheduler when the user clicks the expand icon of a resource tree node that is marked to have dynamic children and whose children have not yet been loaded.

You can use it to provide the child nodes.

Declaration

DayPilot.Scheduler.onLoadNode(args);

Parameters

  • args.resource (object) - the original resource object that was defined using the resources property

  • args.async (boolean) - set this property to true to enable asynchronous loading

  • args.loaded() - call this method to notify the Scheduler that asynchronous loading is complete

Example: Synchronous tree node children loading

Scheduler config:

{
  onLoadNode: (args) => {
    args.resource.children = [
      { name : "Room 111", id : "111"},
      { name : "Room 112", id : "112"}
    ];
  },
  // ...
}

Example: Asynchronous tree node children loading

Scheduler config:

{
  onLoadNode: async (args) => {
    args.async = true;
    const parentId = args.resource.id;
    const {data} = await DayPilot.Http.get(`/api/resourceChildren/${parentId}`);
    args.resource.children = data;
    args.loaded();
  },
  // ...
}