Skip to main content

getResourceColumns

PRO

The functionality is available in PRO Edition only

Description​

Returns the default column configuration for the ResourceLoad component

You can import the helper from @svar/vue-gantt.

Usage​

getResourceColumns(): IResourceColumn[];

IResourceColumn:

{
id: string,
header?: string,
width?: number,
flexgrow?: number,
align?: "left" | "right" | "center",
resize?: boolean,
sort?: boolean | TSortFunction,
getter?: (row: IComputedResource) => any,
template?: (value: any) => string,
cell?: any,
}

Returns​

Returns an array of the default column definitions used by ResourceLoad:

[
{ id: "name", header: "Resources", flexgrow: 1, sort: true, resize: true },
{ id: "total", header: "Hours", width: 80, align: "center", resize: true,
getter: row => row.$total, sort: true },
{ id: "capacity", header: "Capacity", width: 90, align: "center",
getter: row => row.$capacityTotal, sort: true },
]

$capacityTotal is the resource's total available hours over the visible scale range, computed alongside $total and $overloaded.

Example​

Use getResourceColumns() as a starting point when building a custom column set. Call it once and store the result, then insert extra columns between the default ones:

<script setup>
import { Gantt, ResourceLoad, getResourceColumns } from "@svar/vue-gantt";

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

const api = ref(null);

const baseColumns = getResourceColumns();

const columns = [
...baseColumns.slice(0, 1),
{
id: "role",
header: "Role",
align: "center",
flexgrow: 1,
resize: true,
},
{
id: "overloaded",
header: "Overloaded",
width: 100,
align: "center",
getter: row => row.$overloaded,
template: v => (v ? "yes" : "no"),
resize: true,
},
...baseColumns.slice(1),
];
</script>

<template>
<Gantt ref="api" :tasks="tasks" :links="links" :scales="scales" :resources="resources" :assignments="assignments" />
<ResourceLoad :api="api" :columns="columns" />
</template>

Related articles: