Building a project-management screen
What you build
One screen with a task tree grid on the left and a Gantt chart on the right, joined by a draggable splitter. They scroll together, select together and collapse together. A line below shows the selected task. Your server owns every date: the chart only draws, and (from 1.8.0) sends the user's intent to move or resize a bar.
grid (tree) | splitter | Gantt chart
WBS Task Assignee| | Oct Nov
1 Phase A | | [=====summary=====]
1.1 Design | | [==bar==]-->
1.2 Build | | [==bar==]
selected: 1.2 Build - Mia - 2026-11-02 ~ 2026-11-20 - 40%Architecture: who owns what
+--------+ JSON (tasks, dependencies, calendars) +----------+ options, rows +-------------+
| server |---------------------------------------->| host app |------------------>| grid |
| (rules,|<----------------------------------------| | setData +-------------+
| dates) | intents (1.8.0): move, resize, ... | |------------------>| Gantt chart |
+--------+ answer: confirmed changes or refusal +----------+ attachGrid +-------------+| Part | Owns | Does not do |
|---|---|---|
| Server | dates, successor shifting, summary roll-up, calendars, permissions | draw anything |
| Host app | the one list of tasks, fetch and save, the key, the theme variables | change dates by itself |
| Grid | rows, tree, columns, selection, editing of text fields | know about the chart |
| Gantt chart | drawing, zoom, scroll, tooltips, intents | recalculate dates, save |
Data shapes
The chart takes three lists, in one object:
| List | Important fields |
|---|---|
tasks | id (string), parentId (string or null), sortNo, name, status (TODO, IN_PROGRESS, DONE, ON_HOLD, CANCELED), plannedStart and plannedEnd (YYYY-MM-DD or null for unscheduled), progressPct (0 to 100), isMilestone, hasChildren, calendarId, optional wbsCode, assigneeName, version |
dependencies | id, predecessorId, successorId, depType (FS, SS, FF, SF), lagDays |
calendars | id, name, workDays (bit mask Mon=1 ... Sun=64), isDefault, exceptions (date, working, note) |
Dates are plain dates with no time zone. Ids are strings, even when your database uses 64-bit numbers.
If your server answers in snake_case JSON (parent_id, planned_start, has_children, ...), put the server JSON adapter normalizePmsData from @maxgrid/gantt-core between the response and the screen. It turns ids into strings, skips broken items and returns the three lists:
import { normalizePmsData } from '@maxgrid/gantt-core';
const data = normalizePmsData(await (await fetch('/api/projects/7/gantt')).json());Keep one data.tasks list in the host. Make the grid rows from it and give the same object to gantt.setData, so the two views never disagree.
Step by step
1. Install and pin
Use exact versions (no ^) for all @maxgrid/* packages and install them together: @maxgrid/core, @maxgrid/renderer, @maxgrid/license, the wrapper of your framework, @maxgrid/themes, @maxgrid/gantt, @maxgrid/gantt-core. Update them together and on purpose, because the license key has an update deadline.
2. Create the grid, the chart and the splitter
The grid and the chart must use the same rowHeight (32) and the grid's headerHeight must be 48, or the lines drift apart. attachGrid warns once in the console if they differ.
import { createGrid } from 'maxgrid';
import { createGantt, createSplitView } from '@maxgrid/gantt';
import '@maxgrid/themes/grid.css';
import '@maxgrid/gantt/gantt.css';
const grid = createGrid<Row>(gridEl, {
columns: [
{ id: 'wbs', title: 'WBS', width: 64 },
{ id: 'name', title: 'Task', width: 220 },
{ id: 'assignee', title: 'Assignee', width: 100 },
{ id: 'start', title: 'Start', width: 96 },
{ id: 'end', title: 'End', width: 96 },
{ id: 'progress', title: 'Progress (%)', kind: 'number', width: 84, align: 'end' },
],
rows: [],
rowKey: 'id',
rowHeight: 32,
headerHeight: 48,
selection: 'single',
tree: { parentKey: 'parentId', column: 'name', expandDepth: 1 },
ariaLabel: 'Project tasks',
licenseKey,
});
const gantt = createGantt(ganttEl, { rowHeight: 32, locale: 'en', zoom: 'week', licenseKey });
createSplitView({ left: gridEl, right: ganttEl, container: wrapEl, initial: 0.45 });
const unlink = gantt.attachGrid(grid); // scroll, selection and collapse, both waysReact, Vue and Angular have a grid component but no Gantt component. Keep the Gantt imperative inside your own component, and give the splitter the element that holds the grid component as its left pane:
import { useEffect, useRef, useState } from 'react';
import { Grid, type GridApi, type GridOptions } from '@maxgrid/react';
import { createGantt, createSplitView } from '@maxgrid/gantt';
export function ProjectScreen({ options, data }: { options: GridOptions<Row>; data: GanttData }) {
const wrap = useRef<HTMLDivElement>(null);
const left = useRef<HTMLDivElement>(null);
const right = useRef<HTMLDivElement>(null);
const [api, setApi] = useState<GridApi<Row> | null>(null);
useEffect(() => {
if (!api || !wrap.current || !left.current || !right.current) return;
const split = createSplitView({
left: left.current,
right: right.current,
container: wrap.current,
initial: 0.45,
});
const gantt = createGantt(right.current, { rowHeight: 32, locale: 'en', licenseKey });
gantt.setData(data);
const unlink = gantt.attachGrid(api);
return () => {
unlink();
gantt.destroy();
split.destroy();
};
}, [api, data]);
return (
<div ref={wrap} style={{ position: 'relative', height: 520 }}>
<div ref={left}>
<Grid options={options} onReady={({ api }) => setApi(api)} style={{ height: '100%' }} />
</div>
<div ref={right} />
</div>
);
}3. Load, normalize, show
async function load(projectId: string) {
const res = await fetch(`/api/projects/${projectId}/gantt`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const data = normalizePmsData(await res.json());
grid.setRows(data.tasks.map(toRow)); // toRow: task -> { id, parentId, wbs, name, assignee, start, end, progress }
gantt.setData(data);
}Show a loading line while the request runs and an error line when it fails. Reload with setData after a refusal that says the data is stale (for example a version conflict).
4. Show the selected task
gantt.on('row-select', ({ taskId }) => {
detailEl.textContent = taskId ? describe(taskId) : '';
});row-select fires for a click in the grid and in the chart, so one handler is enough. Use api.find(text) for a search box: it marks the matching cells and hides nothing. If you use the grid's filters, sorting or grouping instead, the chart follows the rows the grid shows (hidden rows leave the chart, group headers become empty lines).
5. License key
The key is one line starting with MXG1.. An administrator pastes it into your own settings screen; you store it and put it into the options of every grid and Gantt (the wrappers have no global setting). Create the grids after the key has loaded. For the status screen, the reasons and the allowed host list, see the license guide. Without a valid key everything works and a small evaluation strip is shown.
6. Theme
Colors come from CSS variables only. Map your own tokens once, for light and dark:
:root {
--mxg-bg: var(--app-surface);
--mxg-fg: var(--app-text);
--mxg-border: var(--app-line);
--mxg-gantt-bar: var(--app-accent-soft);
--mxg-gantt-bar-progress: var(--app-accent);
--mxg-gantt-today: var(--app-danger);
}
[data-mxg-theme='dark'] {
/* same names, dark values */
}The full list of --mxg-gantt-* names is in the Gantt guide.
7. Load only on this screen
Import the grid wrapper and the Gantt in a lazy chunk (import() inside your route or async component), and split them from the Vue/React runtime so the first screen of your app does not pay for them. Chunk rules for Vite are in the framework guide.
Editing (available from 1.8.0)
Set editable: true on the chart. A dragged bar then emits an event with an intentId; the bar looks pending; your host sends the change to the server and answers with gantt.applyPatch({ tasks, intentId }) (confirmed values, including successors the server moved) or gantt.revertIntent(intentId) (refusal or timeout). Summary tasks stay read-only because the server decides their dates. Details: the Gantt editing guide.
Performance (measured)
Measured by MaxGrid's automated tests on a generated project of the same shape as a large real plan: 5,000 tasks, 6,000 dependencies, tree depth up to 18. No customer data. Chromium on a shared Linux server; times depend on the device.
| What | Result |
|---|---|
| First bar visible after page load | 122 and 148 ms in two runs (limit 1,000 ms) |
| Scrolling (200 steps each way) | 95th percentile frame gap 16.7 to 17.5 ms (60 frames per second is 16.7 ms) |
| JS heap after scrolling | about 13 MB |
| Chart code | about 30 KB gzip plus about 2.4 KB gzip CSS |
| Grid code (core, renderer, license, wrapper) | about 330 KB gzip, loaded when the first grid appears |
The chart draws only the visible rows and bars, so cost follows the window and not the project size.
Checklist
- [ ] Grid and chart use the same
rowHeight(32) and the gridheaderHeightis 48. - [ ] One task list in the host; grid rows and
setDataboth come from it. - [ ] Ids are strings; dates are
YYYY-MM-DD; unscheduled tasks havenulldates. - [ ] Filters, sorting and grouping on the attached grid are fine: the chart follows the displayed rows. Check one filter and one sort in your own screen.
- [ ] License key set on every grid and Gantt, created after the key is loaded; every host (production, staging, tenant sub-domains) is in the key.
- [ ]
@maxgrid/*versions pinned exactly and updated together. - [ ] Colors mapped with CSS variables for light and dark; contrast checked.
- [ ] Content Security Policy: grid and chart CSS imported statically; no
eval; no network call by the license check. - [ ] Keyboard and screen reader: the grid is fully keyboard operable; bars have a name and dates in their label; the detail line is a
statusregion. Bar keyboard operation is not available yet. - [ ] Destroy order on unmount:
unlink(),gantt.destroy(), splitter destroy, then the grid. - [ ] Editing only from 1.8.0, with a timeout for a server that never answers.
Related
- Gantt chart
- Grid and chart sync (
attachGrid): in the Gantt guide, section "Grid sync" - License key
- Themes
- Gallery:
recipe-project-tool,gantt-basic,gantt-large