I have a simple gantt linked to local datasource (there is no backend api), when adding a task I want to handle the onAdd event and mutate the local datasource.
It seems to work ok except that the id of the new task in onAdd is set to 0 (console.log(e.task) in on Add) - am I supposed to set this id value manually?
7 Answers, 1 is accepted
Hi Al,
Yes, when you add a new Gantt task its id is set to 0 by default. The idea behind this is when you work with a remote datasource to be able to identify if a given task is a new one or one that already exists.
Before you add a new task to your datasource, the task should have its own unique ID. In the context of remote datasource, this unique ID is defined by the remote service.
I hope the above answers your question.
Regards,
Petar
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Thanks Petar. Does the same apply to orderId (need to handle manually)?
It seems that all new tasks get orderId set to 0 even when I choose 'Add below', I'd expected orderId to be set according to where in the gantt the task is added.
Hi Al,
I've tested the following StackBlitz example and I can't replicate the issue with the orderId property. The tasks are correctly added.
Can you check the linked example and let me know if you can replicate the issue that you experience in your application?
Regards,
Petar
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

In that StackBlitz, change the onAdd handler to:
onAdd: function(e) {
console.log(e.task);
}
Click "Task 1" then "Add Above" - it adds the task below "Task 1" (Should be above task task 1?)
Click "Task 1" then "Add Below" - it adds the task below "Task 2" (Should be below task task 1?)
The log shows orderId for both new tasks as zero:
{id: 0, parentId: 1, orderId: 0, title: "New task"…}
{id: 0, parentId: 1, orderId: 0, title: "New task"…}
Hi Al,
Thank you for the shared steps.
For the scenarios with local datasource, when the new task is a subtask you will have to set its orderId manually.
In general, if the local datasource is not a "must have" feature, we would recommend using the Gantt component with a remote datasource.
Regards,
Petar
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Hi Al,
Here is a sample implementation of the Gantt component, configured with a remote data source. If you open the Network tab of your browser you will see that if you add a new task, it is sent to the backend with an OrderID property definition. In the above example, you don't need to set the OrderId manually.
Can you check the above link and maybe compare it to Gantt's remote datasource implementation that you have? Thus you may identify what should be added to the implementation where the OrderId is not defined(in a remote datasource configuration context).
Regards,
Petar
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.