Our state of the art Gantt chart


Post by Jerther »

Hi!

Here's how to reproduce the error.

- Load the Basic demo. It's using Gantt v2.1.2.
- In the code editor, change
new Gantt({
to
window.gantt = new Gantt({
so it's easily accessible in the console.
- In the console, enter this command:
gantt.project.taskStore.add(gantt.project.taskStore.getById(2).copy({deep: true}))
Result:
Cannot read property 'constraintType' of undefined

Expected:
The task tree is duplicated successfully

Additional details:
This works fine if I use {deep: false}

Post by Jerther »

I found that using
copy({deep: true}, false))
The tree is duplicated without error but the dependencies don't follow. The second parameter is not documented but anyway, should I expect the dependencies to also be duplicated?

Post by alex.l »

Hi Jerther,

Thanks for the report, sounds like a bug. I've created a ticket: https://github.com/bryntum/support/issues/756

> The tree is duplicated without error but the dependencies don't follow. The second parameter is not documented but anyway, should I expect the dependencies to also be duplicated?

Dependencies won't be copied even if no bug with { deep : true } option. Second parameter has not been documented because it is for internal use only and this is not a workaround in this situation.

All the best,
Alex


Post by Jerther »

I'll follow the ticket.

Do you have any example where a task tree would be copied including its dependencies? Or maybe just some clue how to do it?

Post by alex.l »

Hi Jerther,

Unfortunately, we don't have an example of copying dependencies.
There is no easy way to do that before we fix the bug we discussed above.
Check Task and TaskModel classes. The dependencies are stored in predecessors and successors. I would advise you to try copying these arrays with the rest of data before creating a new instance.

All best,
Alex

All the best,
Alex


Post by Jerther »

Hi Alex,

I see the github ticket has been resolved for quite a while now, any change of this fix being part of the next release?


Post by mats »

Seems we missed to close this ticket, should be fixed in 2.1.5!


Post by Jerther »

Great!

Now I notice when duplicating a task tree, in the sync request, the task's children have a $PhantomParentId property and also a parentId property both set to the same "_generatedClassDefEx10" value. Is this intentional? I would think that since there is no "id" property, there should be no "parentId" property as well?

Let me know if you need a demo.


Post by alex.l »

Hi Jerther,

Yes, they should be cleaned up, here is the ticket https://github.com/bryntum/support/issues/1002

Thank you for your report!
All best,
Alex

All the best,
Alex


Post by Jerther »

Hi Alex,

I just started working on duplicating a task tree including its dependencies and something is a bit confusing. I was about to duplicate the dependencies (predecessors and successors) of the original task before adding the duplicated task to the taskStore, and I stubled on already existing dependencies in the duplicate. Let me illustrate:

  • Start with the Basic Demo
  • Put the gantt instance on window: window.gantt = new Gantt(...
  • Delete the root task
  • Now in the console, add a new root task:
    var rootTask = gantt.taskStore.rootNode.appendChild({ name : 'New task' })
  • Right click that new task, and add a new subtask
  • Then right that task, and add a new one below
  • Edit the two subtasks and add some duration
  • Then drag a dependency from the end of the first subtask to the start of the second
  • Now in the console, copy the root task:
    var duplicate = rootTask.copy({deep: true})
  • :!: Then look at duplicate.children[0].successors. There's one, and its fromTask and toTask properties are pointing to the original tasks!
  • Add the duplicate to the taskStore:
    gantt.taskStore.add(duplicate)
  • Take another look at duplicate.children[0].successors. Now there is none! And indeed none is shown in the chart.

Not sure if that's intended or not :? I was expecting the duplicated task to have no successor or predecessor.


Post Reply