JavaScript UI Libraries & Blazor Components Suite – Smart UI › Forums › Gantt › Add task click not working › Reply To: Add task click not working
Hi,
You are using the onClick event in which there isn’t event.detail or event.detail.item.
You should you onItemClick and also get the target from here: event.detail.originalEvent.target
Here is the desired method:
handleGanttClick(event: CustomEvent) {
const ganttChart = this.ganttchart?.current;
const eventDetails = event.detail;
const target = event.detail.originalEvent.target;
if (target.classList.contains(‘add-task-button’)) {
const itemIndex = parseInt(
ganttChart?.getItemPath(eventDetails.item).split(‘.’).slice(-1)[0]) + 1,
itemProject = ganttChart?.getItemPath(ganttChart.getTaskProject(eventDetails.item)
);
//Add a new Task
const newItemId = ganttChart?.insertTask(
{
label: ‘New Task’,
dateStart: ganttChart.dateStart
},
itemProject,
itemIndex
);
//Open the Editor to configure
ganttChart?.openWindow(newItemId);
}
}
I hope this helps!
Best Regards,
Svetoslav Borislavov
Smart UI Team
https://www.htmlelements.com/
- This reply was modified 2 years, 2 months ago by svetoslav_borislavov.