getResourceColumns
PRO
The functionality is available in PRO Edition only
Description
Returns the default column configuration for the ResourceLoad componentYou can import the helper from @svar-ui/svelte-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: 70, align: "center",
getter: row => row.$total, sort: true },
]
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>
import { Gantt, ResourceLoad, getResourceColumns } from "@svar-ui/svelte-gantt";
const { tasks, links, scales, resources, assignments } = getData();
let api = $state();
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>
<Gantt bind:this={api} {tasks} {links} {scales} {resources} {assignments} />
<ResourceLoad {api} {columns} />
Related articles: