The onLinkCreate event handler fires when the user finishes creating a link using drag and drop, before the default action configured by DayPilot.Gantt.linkCreateHandling.
DayPilot.Gantt.onLinkCreate(args)args.control (DayPilot.Gantt) - control instance
args.source (DayPilot.Task) - source task
args.target (DayPilot.Task) - target task
args.type (string) - link type: "StartToStart", "StartToFinish", "FinishToStart", or "FinishToFinish"
args.preventDefault() - cancels the default action
Call args.preventDefault() if you want to block the automatic link creation and handle the new dependency yourself.
JavaScript
const gantt = new DayPilot.Gantt("dp", {
linkCreateHandling: "Update",
onLinkCreate: (args) => {
if (args.type === "StartToFinish") {
args.preventDefault();
return;
}
console.log(args.type);
},
// ...
});
gantt.init();Angular
<daypilot-gantt [config]="config"></daypilot-gantt>config: DayPilot.GanttConfig = {
linkCreateHandling: "Update",
onLinkCreate: (args) => {
if (args.type === "StartToFinish") {
args.preventDefault();
return;
}
console.log(args.type);
},
// ...
};React
<DayPilotGantt
linkCreateHandling="Update"
onLinkCreate={onLinkCreate}
{/* ... */}
/>const onLinkCreate = (args) => {
if (args.type === "StartToFinish") {
args.preventDefault();
return;
}
console.log(args.type);
};Vue
<DayPilotGantt
linkCreateHandling="Update"
@linkCreate="onLinkCreate"
<!-- ... -->
/>const onLinkCreate = (args) => {
if (args.type === "StartToFinish") {
args.preventDefault();
return;
}
console.log(args.type);
};