DayPilot.Gantt.onLinkCreate

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

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

DayPilot.Gantt.onLinkCreated

DayPilot.Gantt Class

Availability

Availability of this API item in DayPilot editions:

LitePro
DayPilot for JavaScript