# Resource Tree (JavaScript Scheduler) | DayPilot Pro for JavaScript Demo

> The resources displayed as rows in the Scheduler can be organized in a hierarchy. Read more about the [resource tree](https://doc.daypilot.org/scheduler/resource-tree/) [doc.daypilot.org].

## Links

- Canonical HTML: /demo/scheduler/tree.html
- Source HTML folder: /demo/scheduler/
- Catalog root: /demo/
- Catalog: /demo/llms.txt

## Source

### Inline demo script 1

```javascript
const dp = new DayPilot.Scheduler("dp", {
            startDate: new DayPilot.Date("2026-03-01"),
            cellGroupBy: "Month",
            days: new DayPilot.Date("2026-03-01").daysInMonth(),
            scale: "Day",
            treeEnabled: true,
            resources: [
                {
                    name: "Tools", id: "Tools", expanded: true, children: [
                        {name: "Tool 1", id: "Tool1"},
                        {name: "Tool 2", id: "Tool2"}
                    ]
                },
                {
                    name: "People", id: "People", expanded: true, children: [
                        {name: "Person 1", id: "Person1"},
                        {name: "Person 2", id: "Person2"}
                    ]
                },
                {
                    name: "Locations", id: "Locations", expanded: true, children: [
                        {name: "Location 1", id: "Location1"},
                        {name: "Location 2", id: "Location2"}
                    ]
                },
            ],
            onTimeRangeSelected: async args => {
                const modal = await DayPilot.Modal.prompt("New event name:", "Event");
                dp.clearSelection();
                if (modal.canceled) {
                    return;
                }
                dp.events.add({
                    start: args.start,
                    end: args.end,
                    id: DayPilot.guid(),
                    resource: args.resource,
                    text: modal.result
                });
                dp.message("Created");
            }
        });
        dp.init();

        const app = {
            init() {
                this.loadEventData();
            },
            loadEventData() {
                // generate and load events
                const events = [
                    {
                        start: "2026-03-02T00:00:00",
                        end: "2026-03-04T00:00:00",
                        id: 1,
                        resource: "Tool1",
                        text: "Event #1"
                    },
                    {
                        start: "2026-03-03T00:00:00",
                        end: "2026-03-06T00:00:00",
                        id: 2,
                        resource: "Tool2",
                        text: "Event #2"
                    }
                ];

                dp.update({events});
            }
        };
        app.init();
```

