Skip to main content

sort-resources

PRO

The functionality is available in PRO Edition only

Description​

Fires when the resource grid is sorted

Usage​

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

For handling the actions you can use the Event Bus methods

Parameters​

The callback of the sort-resources action takes an object with the following parameters:

  • key - (required) the column ID to sort by
  • order - (required) sort direction: "asc" for ascending, "desc" for descending
  • add - (optional) if true, appends this sort level to the existing multi-sort order; if false or omitted, replaces the current sort; Default: false

Example​

Use the api.exec method to sort the resource grid programmatically:

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

const { tasks, links, resources, assignments } = getData();

const api = ref(null);

function init(ganttApi) {
api.value = ganttApi;
ganttApi.exec("sort-resources", { key: "name", order: "asc" });
}
</script>

<template>
<div style="height: 60%">
<Gantt
:tasks="tasks"
:links="links"
:resources="resources"
:assignments="assignments"
:init="init"
/>
</div>
<div style="height: 40%">
<ResourceLoad :api="api" />
</div>
</template>

To apply multi-level sorting, call the action again with add: true:

api.exec("sort-resources", { key: "role", order: "asc", add: true });

Related articles: