Skip to main content

delete-assignment

PRO

The functionality is available in PRO Edition only

Description​

Fires when deleting a resource assignment

Usage​

"delete-assignment": ({
id: string | number,
}) => boolean | void;
info

For handling the actions you can use the Event Bus methods. Returning false from the action handler will block the action (see Preventing actions)

Parameters​

The callback of the delete-assignment action can take an object with the following parameters:

  • id - (required) the ID of the assignment to be deleted

Example​

Use the api.exec method to trigger the action:

<script setup>
import { getData } from "./common/data";
import { Gantt } from "@svar/vue-gantt";

const data = getData();
let api = ref();

function init(ganttApi) {
api = ganttApi;
}

function removeAssignment() {
api.exec("delete-assignment", { id: 1 });
}
</script>

<Gantt
:tasks="data.tasks"
:links="data.links"
:scales="data.scales"
:init="init"
/>

Prevent deleting an assignment​

You can intercept the action and return false to block it:

api.intercept("delete-assignment", ev => {
if (!allowDelete) return false; // prevents deletion
});

Related articles: