Our state of the art Gantt chart


Post by malwina »

Hi!

I'd like to ask what the proper and expected way of updating the ID is after creating a task inline. I tried different approaches, and they all resulted in the chart not working as expected for us.

After I create a task on the chart (through addNewAtEnd) and then receive the proper id from the backend, I want to silently update the ID in Gantt so that if the user comes back to that record to change something there, like a name, an update rather than a create request is sent back to the backend.

Using taskStore.getById(phantomId).set('id', newId, true); results in having the name of the other record displayed twice in the name column (that's when you click through the tasks one after another during the create request, and the response comes back while you still click through already existing records - recording in the attachment). The same happens if I try commitAsync after updating silently, or applyChangeset.

Using simply a reference, so record.data.id = newId, or record.set('id', newId, true) does update the id; however, I'm not able to edit that record anymore. Double-clicking the name doesn't do anything for me.

Thanks!
Malwina

Attachments
create-task-inline-bug.mov
(3.85 MiB) Downloaded 77 times

Post by alex.l »

Hi Malwina,

We have it described here https://bryntum.com/products/gantt/docs/guide/Gantt/data/crud_manager_project
All you need is return phantomId with real id from backend in your sync response. See here https://bryntum.com/products/gantt/docs/guide/Gantt/data/crud_manager_project#sync-response-structure

All the best,
Alex Lazarev

How to ask for help? Please read our Support Policy


Post by malwina »

Hi Alex,

Thank you. The thing is that we're using Gantt in Salesforce, so we can't use the standard fetch API. We must load data manually and update the store via applyChangeset. The problem is that when we call applyChangeset to replace a phantom ID with the real ID, it triggers the error from the attachment above. All works well - ID is updated, the record is interactive, and I can edit it later, but the name of the currently edited record is getting duplicated.

Current code:

async createNewTaskRecord(record) {
    const { data } = record;
    const fields = {
      [TASK_OBJECT_NAME.fieldApiName]: data.name,
      [TASK_OBJECT_PHASE.fieldApiName]: this.phase.id,
      [TASK_OBJECT_LIST.fieldApiName]: this.phase.defaultListId
    };
    const recordInput = {
      apiName: TASK_OBJECT.objectApiName,
      fields
    };

this.loading = true;

createRecord(recordInput)
  .then((item) => {
    this.gantt.taskStore.applyChangeset({
      updated: [
        {
          $PhantomId: data.id,
          id: item.id
        }
      ]
    });
  })
  .catch((error) => {
    this.gantt.eventStore.revertChanges();
    this.handleError(error);
  })
  .finally(() => {
    this.loading = false;
  });
  }

Post by alex.l »

Hi,

Make sure you used correct ids, you didn't map idField and phantomId field.
Try to replicate this problem in very basic example? We will be able to debug and confirm a bug or unblock you with a solution.

All the best,
Alex Lazarev

How to ask for help? Please read our Support Policy


Post by malwina »

Hi,

I'm sorry, could you explain what you mean by that? I didn't map idField and phantomId? I checked them, and they were undefined. I'm probably looking at the wrong spot.
I created a Codepen, however, I'm not able to replicate the issue, so I think it must be our configuration issue. But could you please take a look anyway and advise what's wrong? It's a high level example of how I'm updating the field.
Or maybe you have an idea what other issue could cause the behaviour recorded?

https://codepen.io/malwina-g/pen/NPrzear

Thank you!


Post by malwina »

Update - I was able to reproduce the issue in Salesforce.
Recording and a sample component attached.

Gantt 6.0.1
SF Winter '26 Patch 14.22

Attachments
malwiGantt.zip
(8.49 KiB) Downloaded 36 times
salesforce - id update.mov
(15.78 MiB) Downloaded 33 times

Post by alex.l »

Hi Malwina,

Any chance to use v7.x? We do not support 6.0 anymore and don't fix bugs in old versions, unfortunately.

All the best,
Alex Lazarev

How to ask for help? Please read our Support Policy


Post by malwina »

We would very much like to do so, but unfortunately, we've also raised a performance issue in Salesforce in v7.0.1 that blocks us from upgrading to v7.x - https://github.com/bryntum/support/issues/12354

Any chance this has already been addressed?


Post by malwina »

Just checked v6.3.4 - the issue is there as well.

Edit:
Same for 7.1.1, just upgraded to check.
On a side note, the performance seems a lot better than in 7.0.1! Nice!


Post by alex.l »

Hi,

For new created tasks you need to return new id paired with phantom id inside added, not updated.

All the best,
Alex Lazarev

How to ask for help? Please read our Support Policy


Post Reply