Skip to main content

sort-tasks

Description

Fires when sorting tasks

Usage

"sort-tasks": ({
key:string,
order:"asc"|"desc",
add?: boolean,
}) => boolean | void;

Parameters

The callback of the sort-tasks action can take an object with the following parameters:

  • key - (required) data field name
  • order - (required) the sorting direction that can be "asc" or "desc"
  • add - (optional) enables/disables multi-sorting when a new sorting rule is added to an existing sorting order
info

Sorting is enabled by default for all columns except "add-task" (unless overridden in the columns config).

Example

The example below shows how to disable sorting for all columns except the one with id: "text", which remains sortable.

<script>
import { getData } from "./common/data";
import { Gantt } from "wx-svelte-gantt";

const data = getData();
function init(api) {
api.intercept("sort-tasks", (config) => {
return config.key == "text";
});
}
</script>

<Gantt tasks={data.tasks} links={data.links} {init} />

Related articles: