sort-resources
PRO
The functionality is available in PRO Edition only
Description
Fires when the resource grid is sortedUsage
"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 byorder- (required) sort direction:"asc"for ascending,"desc"for descendingadd- (optional) iftrue, appends this sort level to the existing multi-sort order; iffalseor omitted, replaces the current sort; Default:false
Example
Use the api.exec method to sort the resource grid programmatically:
<script setup>
import { getData } from "./common/data";
import { Gantt, ResourceLoad } from "@svar-ui/vue-gantt";
const { tasks, scales, resources, assignments } = getData();
let api = null;
function init(ganttApi) {
api = ganttApi;
api.exec("sort-resources", { key: "name", order: "asc" });
}
</script>
<template>
<Gantt :tasks="tasks" :scales="scales" :resources="resources" :assignments="assignments" :init="init" />
<ResourceLoad :api="api" />
</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: