How to correctly setup a RESTful backend for UrlAdaptor (DataManager, Gantt Chart)
Dear Syncfusion Team:
I was trying to setup a DataManager (with UrlAdaptor) to the Gantt Chart.
To do this, I referred to the following documentations:
- Data binding in EJ2 TypeScript Gantt control | Syncfusion
- Adaptors in EJ2 TypeScript DataManager | Syncfusion
My sample implementation is:
Frontend:
- App.vue
Backend:
-
The RESTful endpoint is:
The data returned by accessing the endpoint `http://localhost:3000/tasks` through a browser are (the format should fit the requirements stated at this link Adaptors in EJ2 TypeScript DataManager | Syncfusion ):
{
"result":
[
{"TaskID":1,"TaskName":"A","StartDate":"2025-06-26T00:00:00.000Z","EndDate":"2025-06-27T09:00:00.000Z","Progress":38,"parentId":null},
...
{"TaskID":7,"TaskName":"F","StartDate":"2025-07-23T00:00:00.000Z","EndDate":"2025-07-25T09:00:00.000Z","Progress":0,"parentId":null}
],
"count":7
}
But the test result is an empty Gantt Chart (no errors or warnings in the console or log files):
But In the same project, I tried JsonAdaptor and WebApiAdaptor sample code from the Documentations simply by modifying App.vue file (no other file or configuration changed), and they both work as expected.
JsonAdaptor Code (Only those that have changed) - App.vue
Data binding in Vue Gantt component | Syncfusion
JsonAdaptor Test Result (Same Project, Same configuration, Same Environment):
WebApiAdaptor Code (Only those that have changed) - App.vue
Data binding in Vue Gantt component | Syncfusion
WebApiAdaptor Test Result (Same Project, Same configuration, Same Environment):
I guess there must be something wrong with my backend RESTful endpoints, please help, thanks a lot!
There are limitations on the length of the thread, i can't paste more code here.
The backend code I was about to paste is (not full code, could be verbose):
electron/main.ts
Hi Ryan,
Greetings from Syncfusion Support,
We have verified the shared details on our end.
When using the Gantt chart with URL Adaptor and a Node.js/Express backend,
we observed that the Gantt chart does not render data when using the GET
method it only displays an empty chart.
This is because, in DataManager, the EJ2 Gantt chart with UrlAdaptor sends POST requests for all actions, including data fetching and CRUD operations. Unlike GET requests, which have limitations on query string length, POST requests allow for larger payloads and are more reliable for data operations. Therefore, using POST is the recommended and more effective approach.
If you prefer to use GET requests, we recommend switching to
the WebApiAdaptor, which sends GET requests for data fetching and
expects the response in the following format:
"Items": a JSON array of records
"Count": the total number of records in the database
Additionally, we have prepared a Gantt chart with a URL adaptor with the
backend as a Node/Express.js sample, and it is attached below. Please refer to
it.
|
<ejs-gantt ref='gantt' id="GanttContainer" :dataSource="data" > ... </ejs-gantt> url: 'http://localhost:3000/tasks', adaptor: new UrlAdaptor(), crossDomain: true, }), taskFields: { id: 'TaskID', name: 'TaskName', startDate: 'StartDate', endDate: 'EndDate', duration: 'Duration', parentID: 'parentId', }, const cors = require('cors'); const bodyParser = require('body-parser');
const api = express(); api.use(cors()); api.use(bodyParser.json());
api.post('/tasks', async(_req, res) => { //const dm = _req.body; const allTasks = [ { TaskID: 1, TaskName: 'Project Initiation', StartDate: '2019-04-02', EndDate: '2019-04-21', parentId: null }, { TaskID: 2, TaskName: 'Identify Site location', StartDate: '2019-04-02', Duration: 4, Progress: 50, parentId: 1 }, { TaskID: 3, TaskName: 'Perform Soil test', StartDate: '2019-04-02', Duration: 4, Progress: 50, parentId: 1 }, { TaskID: 4, TaskName: 'Soil test approval', StartDate: '2019-04-02', Duration: 4, Progress: 50, parentId: 1 }, { TaskID: 5, TaskName: 'Project Estimation', StartDate: '2019-04-02', EndDate: '2019-04-21', parentId: null }, { TaskID: 6, TaskName: 'Develop floor plan', StartDate: '2019-04-04', Duration: 3, Progress: 50, parentId: 5 }, { TaskID: 7, TaskName: 'List materials', StartDate: '2019-04-04', Duration: 3, Progress: 50, parentId: 5 }, { TaskID: 8, TaskName: 'Estimation approval', StartDate: '2019-04-04', Duration: 3, Progress: 50, parentId: 5 }, ];
res.json({ result: allTasks, count: allTasks.length }); });
api.listen(3000, () => console.log('API running on http://localhost:3000')); |
Client sample link: https://stackblitz.com/edit/j9n1in-ya4afkn1?file=src%2FApp.vue
Backend sample link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/gantt-api
If you have any further questions or need additional assistance, please feel free to let us know!
Regards,
Ajithkumar G
- 2 Replies
- 2 Participants
-
RY Ryan.L
- Jul 1, 2025 02:30 PM UTC
- Jul 3, 2025 10:59 AM UTC