Gantt task orderId not set in @add event

1 Answer 66 Views
Gantt wrapper
Al
Top achievements
Rank 1
Iron
Iron
Iron
Al asked on 05 Aug 2021, 08:03 AM

I'm hooking the @add event to show a custom add task screen so I need to call preventDefault , but when I do this it seems that some values are not set correctly:


	ganttAdd: function(e) {					
		//e.task has parentId, orderId, start, end all set correctly
		console.log("ganttAdd", e); 
	}

ganttAdd: function(e) { //e.task only has parentId set correctly, orderId + start + end are not set correctly console.log("ganttAdd", e); e.preventDefault(); }

 

This looks wrong? Also, it is strange because because I'm using 'e' before calling preventDefault so I don't know why this should have any effect.

Petar
Telerik team
commented on 10 Aug 2021, 07:13 AM

Hi, Al. 

We will need some time to check your scenario. I will write you back in the next up to 24 hours with an update regarding the targeted functionality.

Petar
Telerik team
commented on 12 Aug 2021, 02:05 PM

Hi, Al.

I will need to discuss the reported scenario with my colleagues. I will write you back at the beginning of the next week with an update regarding the discussed behavior. Thank you for your understanding and patience.

1 Answer, 1 is accepted

Sort by
0
Petar
Telerik team
answered on 19 Aug 2021, 02:20 PM

Hi Al,

After investigating the targeted functionality with my colleagues, I can confirm that the desired functionality cannot be implemented by preventing the add event. The orderId of the task that is added to the Gantt is being set after the point when we can prevent the add event. This is done to prevent potential performance issues of changing the orderIDs of all siblings of the parent task. 

To achieve the targeted functionality, you will have to define a custom button in the toolbar of the Gantt. This StackBlitz example shows how a custom button can be added to the Gantt's toolbar. By clicking on this custom button, using the below code, you will get the dataItem of the currently selected row. 

$("#command").on("click", function(){
    const gantt = $("#gantt").data("kendoGantt"); 
    var task = gantt.dataItem(gantt.select()[0]);

    console.log(task);
})

The dataItem printed in the console contains the orderId and all the data needed to add a new task in the Gantt. When you have the needed data, the insert method can be used to add a new task to the datasource of the Gantt. 

I hope the above description and the provided example will help you achieve the functionality you need in your app. 

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/.

Tags
Gantt wrapper
Asked by
Al
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Petar
Telerik team
Share this question
or