I’m encountering a problem when I call gantt.load(url, 'json')
from the server. Along with the tasks, I receive collections, which triggers an error:
less
Copy code
datastore.js:40 Uncaught TypeError: Cannot read properties of undefined (reading 'length')
at ot._parseInner (datastore.js:40:29)
at ot.parse (datastore.js:63:21)
at t._process_loading (parsing.js:97:25)
at t.on_load (parsing.js:63:8)
at aa.<anonymous> (ajax_loading.js:22:9)
at ajax.js:180:17
JSON response
{
"tasks": [
{
"id": 29,
"editable": true,
"text": "Dummy Task 1",
"description": null,
"start_date": "24.10.2024.",
"duration": 1,
"progress": 0,
"priority": "normal",
"status": "waiting",
"teams": [
3,
],
"external": [
4
]
},
{
"id": 28,
"editable": true,
"text": "Dummy Task 2",
"description": null,
"start_date": "24.10.2024.",
"duration": 1,
"progress": 0,
"priority": "normal",
"status": "waiting",
"teams": [],
"external": []
},
{
"id": 11,
"editable": true,
"text": "Dummy Task 4",
"description": "Sample description",
"start_date": "24.10.2024.",
"duration": 1,
"progress": 0,
"priority": "normal",
"status": "waiting",
"teams": [
3
],
"external": [
3
]
}
],
"collections": {
"teams": [
{
"value": 2,
"label": "Team A"
},
{
"value": 3,
"label": "Team B"
}
],
"external": [
{
"value": 3,
"label": "External Partner 1"
},
{
"value": 4,
"label": "External Partner 2"
}
]
}
}
When I remove the collections from the response, the error does not occur. However, this also results in the data not being displayed in the Gantt chart. I found a workaround by calling gantt.render();
after a delay of 500ms, but I’m concerned whether this will be a reliable solution in all cases.
Could anyone provide insights on why the presence of collections causes this error and if there’s a more stable solution to ensure the data displays correctly without relying on timeouts?