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
Base URL of your REST API. All endpoint paths are appended to this URL. Do not include a trailing slash.
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.When provided, fetches child tasks and links for a specific parent task ID (lazy loading). When omitted, fetches the full dataset.
Promise<{ tasks: ITask[]; links: ILink[] }>
Dates in the response are automatically parsed from ISO strings to JavaScript Date objects via parseDates().
GET {url}/tasks— all tasksGET {url}/links— all linksGET {url}/tasks/{id}— children of taskidGET {url}/links/{id}— links for taskid
parseDates()
Convertsstart, end, base_start, and base_end string values in a task array to JavaScript Date objects.
Array of task objects with date fields as strings.
ITask[] — the same array with dates converted in-place.
formatDate()
Formats a JavaScriptDate for inclusion in a JSON request body. Returns a string in "yyyy-MM-dd HH:mm:ss" format.
The date to format.
string
sendBatch()
Sends a request, either directly or via the batch queue ifbatchURL is configured.
Relative URL path, e.g.
"tasks/42".HTTP method:
"GET", "POST", "PUT", "DELETE".Request body. Date values are automatically formatted via
formatDate().Additional HTTP headers to merge with the default
Content-Type: application/json.Promise<T>
send()
Sends a single HTTP request directly, bypassing the batch queue.Relative URL path.
HTTP method.
Request body.
Additional HTTP headers.
Promise<T>
REST API endpoints
RestDataProvider expects the following endpoints on your backend:
Tasks
| Method | Path | Description |
|---|---|---|
GET | /tasks | Return all root-level tasks |
GET | /tasks/{id} | Return child tasks of task {id} (lazy load) |
POST | /tasks | Create a new task |
PUT | /tasks/{id} | Update task {id}, or perform a copy / move operation |
DELETE | /tasks/{id} | Delete task {id} |
id:
Links
| Method | Path | Description |
|---|---|---|
GET | /links | Return all links |
GET | /links/{id} | Return links for task {id} (lazy load) |
POST | /links | Create a new link |
PUT | /links/{id} | Update link {id} |
DELETE | /links/{id} | Delete link {id} |
Batch mode
WhenbatchURL is configured, multiple rapid changes (e.g. during drag-and-drop) are queued and sent as a single POST request to reduce network overhead.
POST {url}/batch:
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: