Our pure JavaScript Scheduler component


Post by hyco »

Issue

When the resource ID changes, its display changes and its event disappears.

bryntum_tasks_disapears.gif
bryntum_tasks_disapears.gif (149.92 KiB) Viewed 568 times

Implementation to reproduce

import { BryntumScheduler } from "@bryntum/scheduler-react";

const App = () => {
  const [data, setData] = useState({
    resources: [
      {
        id: "doing",
        name: "doing",
        expended: true,
        children: [
          {
            id: "_generatedClassDefEx3",
            name: "Nouvelle tâche",
            status: "doing",
          },
        ],
      },
    ],
    events: [
      {
        id: 0,
        resourceId: "_generatedClassDefEx3",
        eventColor: "orange",
        startDate: "2022-01-11T23:00:00.000Z",
        endDate: "2022-01-12T23:00:00.000Z",
      },
    ],
  });

  const updateData = () => {
    setData({
      resources: [
        {
          id: "doing",
          name: "doing",
          expended: true,
          children: [
            {
              id: "task1",
              name: "Nouvelle tâche",
              status: "doing",
            },
          ],
        },
      ],
      events: [
        {
          id: 0,
          resourceId: "task1",
          eventColor: "orange",
          startDate: "2022-01-11T23:00:00.000Z",
          endDate: "2022-01-12T23:00:00.000Z",
        },
      ],
    })
  }

  const schedulerConfig = {
    columns: [{ field: "name", text: "columnTitle", width: 100, type: "tree" }],
    resources: data.resources,
    events: data.events,
    features: {
      tree: true,
    },
  };

  return (
    <>
      <button onClick={updateData}>post</button>
      <BryntumScheduler {...schedulerConfig} />
    </>
  );
};

export default App;

Thanks for help :)
Best regards


Post by saki »

Events are always linked to resource by ids of resources - each event has resourceId. When the id of the resource changes the link between the resource and event is broke so the event disappears.

So far the explanation, now, why should id of any record change in the first place? Id is an identification so when that changes the record changes (or is at least considered as being a different record with a different identity).


Post by hyco »

Hi Saki thank you for your response,

In my case there is a step which IDs are temporal and will be replaced by the persisted IDs fetched from the server.

So, in my example, resources and events are updated with new Data and are already linked by IDs.

IMHO, when we update the resources and the events, the scheduler should considerate them as a new data and should invalidate the cache, or at least support that an event's link can be updated.


Post by saki »

I've run your showcase and I found that there's one mechanism in effect here and that is syncDataOnLoad This flag is turned on by the wrapper. However, the whole logic of syncing only changed records relies on ids so if an id changed it gets fooled. The solution is to turn it off while configuring the Scheduler:

  const schedulerConfig = {
    columns: [{ field: "name", text: "columnTitle", width: 100, type: "tree" }],
    resources: data.resources,
    events: data.events,
    treeFeature: true,
    resourceStore : {
        syncDataOnLoad: false
    },
    eventStore : {
        syncDataOnLoad : false
    }
  };

Post by hyco »

Hi Saki,

It resolves my issue, thank you for this solution.

Have a nice day :)
Best regards


Post Reply