# Gantt Toolbar
URL: https://pro.rv-grid.com/api/gantt-toolbar/
Source: src/content/docs/api/gantt-toolbar.md
### `getGanttBaselineCaptureRuntime`

```ts
export async function getGanttBaselineCaptureRuntime(
  grid: HTMLRevoGridElement,
): Promise<GanttBaselineCaptureRuntime | undefined>;
```

---

### `captureGanttBaseline`

```ts
export async function captureGanttBaseline(
  grid: HTMLRevoGridElement,
  options?: CaptureBaselineOptions,
): Promise<BaselineSnapshot | null>;
```

---

### `GanttBaselineCaptureRuntime`

```ts
interface GanttBaselineCaptureRuntime {
  captureBaseline(options?: CaptureBaselineOptions): BaselineSnapshot | null
}
```

---

### `toggleGanttCriticalPath`

Toggle critical-path highlighting on the grid's Gantt visual config.

Returns the next visibility state, or `undefined` when the grid has no
Gantt config to update.

```ts
export function toggleGanttCriticalPath(grid: HTMLRevoGridElement): boolean | undefined;
```

---

### `getCsvExportPlugin`

```ts
export async function getCsvExportPlugin(grid: HTMLRevoGridElement): Promise<RevoGridCsvExportPlugin | undefined>;
```

---

### `exportGanttCsv`

```ts
export async function exportGanttCsv(
  grid: HTMLRevoGridElement,
  options: GanttCsvExportOptions =;
```

---

### `exportGanttExcel`

```ts
export function exportGanttExcel(
  grid: HTMLRevoGridElement,
  options: GanttExcelExportOptions =;
```

---

### `GanttCsvExportOptions`

```ts
interface GanttCsvExportOptions {
  filename?: string;
  bom?: boolean;
  columnDelimiter?: string;
  rowDelimiter?: string;
  mime?: string;
  encoding?: string
}
```

---

### `GanttExcelExportOptions`

```ts
export type GanttExcelExportOptions = ExportExcelEvent;
```

---

### `RevoGridCsvExportPlugin`

```ts
interface RevoGridCsvExportPlugin {
  exportFile(options?: GanttCsvExportOptions): Promise<void>
}
```

---

### `getGanttTimelineNavigationRuntime`

```ts
export async function getGanttTimelineNavigationRuntime(
  grid: HTMLRevoGridElement,
): Promise<GanttTimelineNavigationRuntime | undefined>;
```

---

### `scrollGanttToToday`

```ts
export async function scrollGanttToToday(
  grid: HTMLRevoGridElement,
  options: GanttTodayNavigationOptions =;
```

---

### `fitGanttToProject`

```ts
export async function fitGanttToProject(
  grid: HTMLRevoGridElement,
  options: GanttProjectFitOptions =;
```

---

### `GanttTimelineNavigationOptions`

```ts
interface GanttTimelineNavigationOptions {
  align?: number
}
```

---

### `GanttTodayNavigationOptions` (Extended from `index.ts`)

```ts
interface GanttTodayNavigationOptions {
  date?: ISODateString
}
```

---

### `GanttProjectFitOptions` (Extended from `index.ts`)

```ts
interface GanttProjectFitOptions {
  viewportWidth?: number
}
```

---

### `GanttTimelineNavigationRuntime`

```ts
interface GanttTimelineNavigationRuntime {
  scrollToToday?: () => Promise<void> | void;
  fitToProject?: () => Promise<void> | void;
  getZoomLevel?: () => { id?: string } | null | undefined;
  setZoomLevel?: (levelId: string) => boolean
}
```

---

### `createGanttToolbarQuickWinActions`

Framework-neutral command descriptors for common Gantt toolbar additions.

Render the returned commands in any toolbar UI and call `run()` from the
button handler. Creating the descriptors does not dispatch events, scroll, or
mutate the grid.

```ts
export function createGanttToolbarQuickWinActions(
  grid: HTMLRevoGridElement,
  options: GanttToolbarQuickWinOptions =;
```

---

### `listGanttToolbarQuickWinActions`

```ts
export function listGanttToolbarQuickWinActions(
  actions: GanttToolbarQuickWinActions,
): readonly GanttToolbarQuickWinAction[];
```

---

### `GanttToolbarQuickWinActionId`

```ts
export type GanttToolbarQuickWinActionId =
  | 'export-csv'
  | 'export-excel'
  | 'capture-baseline'
  | 'toggle-critical-path'
  | 'timeline-today'
  | 'timeline-fit-project';
```

---

### `GanttToolbarQuickWinAction`

```ts
interface GanttToolbarQuickWinAction {
  readonly id: GanttToolbarQuickWinActionId;
  readonly label: string;
  readonly title: string;
  readonly run: () => Result | Promise<Result>
}
```

---

### `GanttToolbarQuickWinOptions`

```ts
interface GanttToolbarQuickWinOptions {
  readonly csv?: GanttCsvExportOptions | false;
  readonly excel?: GanttExcelExportOptions | false;
  readonly baseline?: CaptureBaselineOptions | false;
  readonly criticalPath?: false;
  readonly today?: GanttTodayNavigationOptions | false;
  readonly fitToProject?: GanttProjectFitOptions | false
}
```

---

### `GanttToolbarQuickWinActions`

```ts
interface GanttToolbarQuickWinActions {
  readonly exportCsv?: GanttToolbarQuickWinAction<boolean>;
  readonly exportExcel?: GanttToolbarQuickWinAction<CustomEvent<GanttExcelExportOptions>>;
  readonly captureBaseline?: GanttToolbarQuickWinAction<BaselineSnapshot | null>;
  readonly toggleCriticalPath?: GanttToolbarQuickWinAction<boolean | undefined>;
  readonly scrollToToday?: GanttToolbarQuickWinAction<boolean>;
  readonly fitToProject?: GanttToolbarQuickWinAction<boolean>
}
```

---

### `resolveHiddenColumnsFromToolbarSelection`

```ts
export function resolveHiddenColumnsFromToolbarSelection(
  selectedValues: string | string[],
  allProps: string[],
  previousHiddenColumns: string[],
): string[];
```

---

### `GANTT_TOOLBAR_SELECT_ALL_COLUMNS`

```ts
GANTT_TOOLBAR_SELECT_ALL_COLUMNS: string;
```

---

### `GanttToolbar`

```ts
GanttToolbar: ({ grid, columns, visuals: initialVisuals, controls }: GanttToolbarComponentProps) => preact.JSX.Element;
```

---

### `GanttToolbarColumnOption`

A single column entry shown in the Gantt toolbar column-visibility dropdown.

```ts
interface GanttToolbarColumnOption {
  /** Property name matching a task-table column (e.g. `'wbs'`, `'status'`). */
    prop: string;
  /** Human-readable label shown in the dropdown. */
    label: string;
  /**
     * Whether the column is visible by default.
     * Columns with `visible: false` will be added to `grid.hideColumns` on mount.
     * @default true
     */
    visible?: boolean
}
```

---

### `GanttToolbarVisuals`

Initial visual toggle state passed to the toolbar.

```ts
interface GanttToolbarVisuals {
  showBaseline?: boolean;
  showDependencies?: boolean;
  showCriticalPath?: boolean
}
```

---

### `GanttToolbarControls`

Visibility switches for each toolbar control or control group.

```ts
interface GanttToolbarControls {
  search?: boolean;
  history?: boolean;
  undo?: boolean;
  redo?: boolean;
  tree?: boolean;
  expandAll?: boolean;
  collapseAll?: boolean;
  zoom?: boolean;
  zoomIn?: boolean;
  zoomOut?: boolean;
  tasks?: boolean;
  addTask?: boolean;
  indent?: boolean;
  outdent?: boolean;
  export?: boolean;
  exportExcel?: boolean;
  columns?: boolean;
  dependencies?: boolean;
  baseline?: boolean;
  criticalPath?: boolean
}
```

---

### `GanttToolbarOptions`

Options accepted by {@link defineGanttToolbar}.

```ts
interface GanttToolbarOptions {
  /** The `revo-grid` element the toolbar should control. */
    grid: HTMLRevoGridElement;
  /**
     * Column options to show in the visibility dropdown.
     * If omitted, no column dropdown is rendered.
     */
    columns?: GanttToolbarColumnOption[];
  /**
     * Initial state of the visual/scheduling toggles.
     * When omitted, values are read from the current `grid.gantt.visuals` config.
     */
    visuals?: GanttToolbarVisuals;
  /**
     * Per-control visibility. Omitted options default to visible, except
     * `baseline`, which is opt-in to keep the default command bar compact.
     */
    controls?: GanttToolbarControls
}
```

---

### `ganttToolbarDependencies`

#### Dependencies

- **Optional** `HistoryPlugin`: Integrates with HistoryPlugin undo and redo controls when present.
- **Optional** `GanttPlugin`: Integrates with Gantt runtime zoom and editing capabilities when present.
- **Event integration** `gantt-runtime`: Dispatches and listens to Pro and Gantt events for toolbar controls.

```ts
ganttToolbarDependencies: PluginDependency[];
```

---

### `defineGanttToolbar`

Mounts the Gantt editing toolbar into `el` and wires it to the given
`revo-grid` element.  Call this once after the grid's `gantt` property
has been set so the toolbar can read the initial visual config.

`controls` hides built-in controls. Omitted flags are visible by default,
except `baseline`, which is opt-in.

### Example
```ts
import { defineGanttToolbar } from '@revolist/revogrid-enterprise';

const toolbarEl = document.querySelector('#gantt-toolbar');
const grid      = document.querySelector('revo-grid');

defineGanttToolbar(toolbarEl, {
  grid,
  columns: [
    { prop: 'wbs',       label: 'WBS',       visible: true  },
    { prop: 'name',      label: 'Name',       visible: true  },
    { prop: 'startDate', label: 'Start Date', visible: true  },
    { prop: 'duration',  label: 'Duration',   visible: true  },
    { prop: 'status',    label: 'Status',     visible: true  },
    { prop: 'endDate',   label: 'End Date',   visible: false },
  ],
  visuals: {
    showDependencies:            true,
    showBaseline:                true,
    showCriticalPath:            true,
  },
  controls: {
    search: true,
    history: true,
    undo: true,
    redo: true,
    tree: true,
    expandAll: true,
    collapseAll: true,
    zoom: true,
    zoomIn: true,
    zoomOut: true,
    tasks: true,
    addTask: true,
    indent: true,
    outdent: true,
    export: true,
    exportExcel: true,
    columns: true,
    dependencies: true,
    baseline: true,
    criticalPath: true,
  },
});
```

```ts
defineGanttToolbar: (el: HTMLElement, options: GanttToolbarOptions) => void;
```
