Skip to main content
RestDataProvider is a built-in data provider that syncs Gantt operations to a REST API. It handles all CRUD operations for tasks and links, with optional batch request support to reduce network round-trips.

Installation

RestDataProvider is shipped in a separate package:

Quick start

Constructor

string
required
Base URL of your REST API. All endpoint paths are appended to this URL. Do not include a trailing slash.
string
When provided, multiple rapid changes are queued and sent as a single batch POST request to this URL instead of individual requests. Useful for reducing server load during drag-and-drop operations.

Methods

getData()

Fetches tasks and links from the server.
string | number
When provided, fetches child tasks and links for a specific parent task ID (lazy loading). When omitted, fetches the full dataset.
Returns: Promise<{ tasks: ITask[]; links: ILink[] }> Dates in the response are automatically parsed from ISO strings to JavaScript Date objects via parseDates().
Endpoints called:
  • GET {url}/tasks — all tasks
  • GET {url}/links — all links
  • GET {url}/tasks/{id} — children of task id
  • GET {url}/links/{id} — links for task id

parseDates()

Converts start, end, base_start, and base_end string values in a task array to JavaScript Date objects.
ITask[]
required
Array of task objects with date fields as strings.
Returns: ITask[] — the same array with dates converted in-place.

formatDate()

Formats a JavaScript Date for inclusion in a JSON request body. Returns a string in "yyyy-MM-dd HH:mm:ss" format.
Date
required
The date to format.
Returns: string

sendBatch()

Sends a request, either directly or via the batch queue if batchURL is configured.
string
required
Relative URL path, e.g. "tasks/42".
string
required
HTTP method: "GET", "POST", "PUT", "DELETE".
any
Request body. Date values are automatically formatted via formatDate().
object
Additional HTTP headers to merge with the default Content-Type: application/json.
Returns: Promise<T>

send()

Sends a single HTTP request directly, bypassing the batch queue.
string
required
Relative URL path.
string
required
HTTP method.
any
Request body.
object
Additional HTTP headers.
Returns: Promise<T>

REST API endpoints

RestDataProvider expects the following endpoints on your backend:

Tasks

POST /tasks request body:
The server must return the created task including its server-assigned id:
PUT /tasks/ — update:
PUT /tasks/ — copy operation:
PUT /tasks/ — move operation:
POST /links request body:
The server must return the created link’s ID:

Batch mode

When batchURL is configured, multiple rapid changes (e.g. during drag-and-drop) are queued and sent as a single POST request to reduce network overhead.
If multiple changes occur within a 10 ms window, they are merged into a single request to POST {url}/batch:
If only one change occurs in the window, it is sent as a normal individual request (not to the batch URL).
Dates are automatically serialized to "yyyy-MM-dd HH:mm:ss" format in all request bodies.

ID mapping

RestDataProvider maintains a queue that maps temporary client-side IDs (assigned immediately after add-task / add-link) to the permanent IDs returned by the server. Subsequent operations that reference those IDs use the server-assigned ID automatically. This means you can chain operations without waiting for server responses:

Example with lazy loading

Mark tasks as lazy by setting a custom lazy: true property. The Gantt will fire request-data when the user expands them instead of trying to render their (missing) children.