Our state of the art Gantt chart


Post by tso »

Hello,

We're trying to overwrite the DependencyModel of a DependencyStore. We have custom from/to fields and would like to avoid manually mapping our dependencies. Our use case is pretty much 1:1 with the example in the documentation, see https://www.bryntum.com/docs/gantt/#Gantt/model/DependencyModel . However, it does not seem to work. I have attached an html file that should allow you to easily run this.

Two problems:
1) If I provide to/from keys for my dependencies they are not shown correctly. I have to use toTask/fromTask. This is not clear from the documentation (I had to look at the response from one of your examples).

2) I cannot remap to/from (nor toTask/fromTask or even toEvent/fromEvent) to myTo/myFrom using the dataSource key when overriding the fields. Am I defining my custom model incorrectly or plugging it in the wrong place?

Let me know if you need any additional information.

Thanks!

I could not attach the .html file so I have to copy-paste it here. Sorry about that.
<html lang="en">
	<head>
        <meta charset="utf-8"/>
        <script src="https://www.bryntum.com/examples/build/gantt.module.js" type="module"></script>
        <link rel="stylesheet" type="text/css" href="https://www.bryntum.com/examples/build/gantt.default.css"/>

        <script type="module">
            import {Gantt, TaskModel, TaskStore, DependencyStore, DependencyModel} from 'https://www.bryntum.com/examples/build/gantt.module.js';

            class MyDependencyModel extends DependencyModel {
                static get fields() {
                    return [
                        // Mentioned in the documentation
                        {name: 'to', dataSource: 'myTo'},
                        {name: 'from', dataSource: 'myFrom'},
                        
                        // Other attempts
                        // {name: 'toTask', dataSource: 'myTo'},
                        // {name: 'fromTask', dataSource: 'myFrom'},
                        // {name: 'toEvent', dataSource: 'myTo'},
                        // {name: 'fromEvent', dataSource: 'myFrom'},
                    ];
                }
            }

            const gantt = new Gantt({
                autoHeight: true,
                appendTo: 'gantt',
                taskStore: new TaskStore({
			        modelClass: TaskModel,
			    }),
                dependencyStore: new DependencyStore({
                    modelClass: MyDependencyModel,
                }),
            });

			gantt.taskStore.data = [
            {
                "id": 1,
			    "name": "Task 1",
			    "startDate": "2019-10-18",
			    "endDate": "2019-10-22",
			    "expanded": true,
			    "children": [
			      {
			        "id": 2,
			        "name": "Task 2",
			        "startDate": "2019-10-18",
			        "endDate": "2019-10-19"
			      },
			    ]
			  }
			];

            gantt.dependencyStore.data = [
            {
                "id": "d1",
                "myTo": 1,
                "myFrom": 2
              }
            ];
           
        </script>
	</head>

	<body>
        <div id="gantt"></div>
	</body>
</html>

Post by Maxim Gorkovsky »

Hello.
I can reproduce this problem. Here is a ticket: https://app.assembla.com/spaces/bryntum/tickets/9393-impossible-to-override-dependency-fields-in-gantt/details

Thank you for report!

I also noted that doc is a bit outdated. So far it appears the only way to define working dependency via the data would be to provide exact config:
{
  id : 1,
  fromEvent : 1,
  toEvent : 2
}

Post by tso »

Hi Maxim,

Thanks for tracking our issue. Is there a difference between fromEvent/toEvent and fromTask/toTask? Both seem to work for us.

Post by sergey.maltsev »

Hi, tso!

Dependency model has
https://www.bryntum.com/docs/gantt/#Gantt/model/DependencyModel#field-fromEvent
https://www.bryntum.com/docs/gantt/#Gantt/model/DependencyModel#field-toEvent

So I'd suggest to use fromEvent / toEvent.
But actually they are field aliases.

Post by tso »

I see, thank you.

Post Reply