After task updated. i cant delete that task .
it gives “Cannot read property ‘id’ of undefined” error message.
here is my code
clickGridButton = function (id, action) {
currentActiveParentId = id;
switch (action) {
case “edit”:
gantt.showLightbox(id);
break;
case "add":
gantt.createTask(null, id);
break;
case "delete":
gantt.refreshTask(id);
dhtmlx.confirm({
title: gantt.locale.labels.confirm_deleting_title,
text: gantt.locale.labels.confirm_deleting,
callback: function (res) {
if (res)
console.log(gantt.getTask(id));
gantt.deleteTask(id);
}
});
break;
}
};
var colHeader = ‘
’,colContent = function (task) {
return (’’ +
‘’ +
‘’);
};
var colPredecessorHeader = '<div class="gantt_grid_head_cell gantt_grid_head_predecessor " style="width:140px;text-align:left;" column_id="predecessor">Predecessor(s)</div>';
gantt.config.columns = [
{ name: "no", label: "No.", tree: true, align: "left", width: '110' },
{ name: "phase", label: "Phase/Subphase", align: "left", width: '130' },
{ name: "start_date", label: "Start Date", align: "center", width: '120' },
{ name: "end_date", label: "End Date", align: "center", width: '120' },
{
name: "duration", label: "Duration", align: "center", width: '80',
template: function (obj) {
return obj.duration + " days"
}
},
{
name: "predecessor", label: colPredecessorHeader, align: "left", width: '140',
template: function (obj) {
if (obj.$target != 0 && obj.$target != "") {
var links = gantt.getLink(obj.$target);
var phasePred;
if (links.source != null && links.source != "") {
phasePred = gantt.getTask(links.source)
obj.predecessor = phasePred.no;
} else { obj.predecessor = 'N/A'; }
}
else {
obj.predecessor = 'N/A';
}
return obj.predecessor;
}
},
{ name: "bid", label: "Bid(s)", align: "center", width: '70' },
{ name: "tasktype", hide: true},
{ name: "team", label: "Team Members", align: "center", width: '130' },
{
name: "buttons",
label: colHeader,
width: 90,
align: "center",
template: colContent,
hide: toHide
}
];