search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Resources Calendar does not schedule events at all

Related article: React Scheduler with a Vertical Timeline
Asked by Samir
17 days ago.

Hello,

The resource calendar has a bug in it. Unfortunately, when I attempt to schedule events with the DayPilotCalendar viewType set to “resources”, no events show. Please note that this is code copied directly from the article, I would expect it to work, and yet it does not.

You may find the code attached. You may need to remove some of my own code, namely the useRosterStore and various custom types, however the page should function without. You will need the Mantine react component library installed properly.

All the best,

Samir
samirjbuch@gmail.com

Answer posted by Dan Letecky [DayPilot]
16 days ago.

Hi Samir,

With the following setup, the resource calendar will display one day on the vertical axis. As the startDate is not specified, it will use the current day for all columns/resources.

<DayPilotCalendar
  viewType="Resources"
  controlRef={setCalendar}
  columns={[
    { name: "Resource A", id: "A" },
    { name: "Resource B", id: "B" },
    { name: "Resource C", id: "C" },
    { name: "Resource D", id: "D" },
    { name: "Resource E", id: "E" },
    { name: "Resource F", id: "F" },
    { name: "Resource G", id: "G" }
  ]}
  heightSpec="BusinessHoursNoScroll"

  businessBeginsHour={9}
  businessEndsHour={17}
/>

The events array only contains events in a range from May 2 to May 5, 2024.

const events = [
  {
    id: 1,
    text: "Event 1",
    start: "2024-05-02T00:00:00",
    end: "2024-05-05T00:00:00",
    resource: "A",
    owner: "AB"
  },
  {
    id: 2,
    text: "Event 2",
    start: "2024-05-03T00:00:00",
    end: "2024-05-05T00:00:00",
    resource: "C",
    barColor: "#5bbe2d",
    barBackColor: "#93c47d",
    owner: "BK"
  },
  {
    id: 3,
    text: "Event 3",
    start: "2024-05-02T00:00:00",
    end: "2024-05-04T00:00:00",
    resource: "D",
    barColor: "#f1c232",
    barBackColor: "#f1c232",
    owner: "FH"
  },
  {
    id: 4,
    text: "Event 3",
    start: "2024-05-02T00:00:00",
    end: "2024-05-04T00:00:00",
    resource: "E",
    barColor: "#cc4125",
    barBackColor: "#ea9999",
    owner: "IG"
  }
];

console.log(events);

const columns = [
  { name: "Resource A", id: "A" },
  { name: "Resource B", id: "B" },
  { name: "Resource C", id: "C" },
  { name: "Resource D", id: "D" },
  { name: "Resource E", id: "E" },
  { name: "Resource F", id: "F" },
  { name: "Resource G", id: "G" }
];

calendar.update({ events, columns });

If you change the date to "2024-05-02", you should see events in columns A, D, and E.

<DayPilotCalendar
  viewType="Resources"
  startDate={"2024-05-02"}
  controlRef={setCalendar}
  columns={[
    { name: "Resource A", id: "A" },
    { name: "Resource B", id: "B" },
    { name: "Resource C", id: "C" },
    { name: "Resource D", id: "D" },
    { name: "Resource E", id: "E" },
    { name: "Resource F", id: "F" },
    { name: "Resource G", id: "G" }
  ]}
  heightSpec="BusinessHoursNoScroll"

  businessBeginsHour={9}
  businessEndsHour={17}
/>

Another option is to change the scale to display the full month.

Example:

<DayPilotCalendar
  startDate={"2024-05-01"}
  days={31}
  scale={"Day"}
  // ...
/>

Let me know if the problem persists.

New Reply
This reply is
Attachments:
or drop files here
Your name (optional):