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.
Declaration
DayPilot.Gantt.onLinkCreate(args)Parameters
args.control(DayPilot.Gantt) - control instanceargs.source(DayPilot.Task) - source taskargs.target(DayPilot.Task) - target taskargs.type(string) - link type:"StartToStart","StartToFinish","FinishToStart", or"FinishToFinish"args.preventDefault()- cancels the default action
Notes
Call args.preventDefault() if you want to block the automatic link creation and handle the new dependency yourself.
Examples
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);
};See Also
DayPilot.Gantt.linkCreateHandling
Availability
Availability of this API item in DayPilot editions:
| Product | Lite | Pro |
|---|---|---|
| DayPilot for JavaScript |
DayPilot