- Home
- Forum
- Angular - EJ 2
- Null reference error when trying to add a task
Null reference error when trying to add a task
Hi, I have the add feature enabled in the toolbar. However, when I try to add a task, the spinner shows, and the dialog is not opened. In the console I get following error:
Hi Niels,
Greetings from Syncfusion.
Regarding the issue you are experiencing, we made several attempts to replicate it on our end but were unable to reproduce the issue. Here’s a summary of our validation steps:
Removed the unit field from the resourceFields property.
Added unit values directly to the resource data source without including the unit field.
Tested scenarios with and without the unit field in the resourceFields property and resource data source. (refer sample)
To assist you further, please share the following additional details:
The version of the Gantt Chart you are using.
Code snippets related to your columns, resourceFields, and taskFields.
The data structure for both resourceData and GanttData.
Are you customized anything with actionBegin/actionCompete event?
Sample - Dzu67h (forked) - StackBlitz
Regards,
Sridharan
Hi, I am using version 27.2.4 of the Gantt Chart
The data I receive is this:
[
{
"id": 11,
"parentId": null,
"title": "Teststap Parent 1 - UPDATE",
"description": "To be added later?",
"startDate": "2024-11-20T12:41:45.646",
"endDate": "2024-12-05T12:41:44.646",
"isMilestone": false,
"percentCompleted": null,
"dependency": "",
"status": {
"enumKey": 2,
"id": 30,
"name": "Planned"
},
"pilot": null,
"concurrency": "AAAAAAAEb6o=",
"resources": [
{
"id": 1,
"resourceType": 1,
"employee": {
"amei": "1088448",
"id": 2,
"name": "Niels VAN GOETHEM"
},
"function": null
},
{
"id": 2,
"resourceType": 1,
"employee": {
"amei": "518345",
"id": 1,
"name": "KINGSLEY NESEN"
},
"function": null
}
]
},
{
"id": 14,
"parentId": null,
"title": "Teststap - ADD",
"description": "To be added later?",
"startDate": "2024-11-20T12:41:45.646",
"endDate": "2025-02-21T12:41:44.646",
"isMilestone": false,
"percentCompleted": null,
"dependency": "",
"status": {
"enumKey": 2,
"id": 30,
"name": "Planned"
},
"pilot": null,
"concurrency": "AAAAAAAEb6s=",
"resources": [
{
"id": 1,
"resourceType": 1,
"employee": {
"amei": "1088448",
"id": 2,
"name": "Niels VAN GOETHEM"
},
"function": null
},
{
"id": 2,
"resourceType": 1,
"employee": {
"amei": "518345",
"id": 1,
"name": "KINGSLEY NESEN"
},
"function": null
},
{
"id": 3,
"resourceType": 2,
"employee": null,
"function": {
"id": 1,
"name": "Developer"
}
}
]
},
{
"id": 19,
"parentId": null,
"title": "New Task 3",
"description": "To be added later?",
"startDate": "2024-11-20T12:41:45.646",
"endDate": "2024-11-20T12:41:45.646",
"isMilestone": true,
"percentCompleted": null,
"dependency": "",
"status": {
"enumKey": 2,
"id": 30,
"name": "Planned"
},
"pilot": null,
"concurrency": "AAAAAAAEb6w=",
"resources": []
}
]
Which I map to 2 different datasets:
I have successfully replicated the issue in this stackblitz:
Dzu67h (forked) - StackBlitz
I have found that the problem was caused by having emty values in the resources. By passing an empt
Niels,
Thank you for sharing the sample and details. We have run your sample and performed the add action, which works as expected without the reported console error. Upon validating your data source, we noticed that the id for your resources has been incorrectly set, with the same id being assigned to all resources.
Code-Snippet:
data.ts:- export let dataSet: any[] = [ { id: 11, parentId: null, title: 'Teststap Parent 1 - UPDATE', description: 'To be added later?', startDate: '2024-11-20T12:41:45.646', endDate: '2024-12-05T12:41:44.646', isMilestone: false, percentCompleted: null, dependency: '', status: { enumKey: 2, id: 30, name: 'Planned', }, pilot: { amei: '1088448', id: 1, name: 'Niels VAN GOETHEM 1', }, concurrency: 'AAAAAAAEb6o=', resources: [ { id: 1, resourceType: 1, employee: { amei: '1088448', id: 2, name: 'Niels VAN GOETHEM', }, function: null, }, { id: 2, resourceType: 1, employee: { amei: '518345', id: 1, name: 'KINGSLEY NESEN', }, function: null, }, ], }, { id: 14, parentId: null, title: 'Teststap - ADD', description: 'To be added later?', startDate: '2024-11-20T12:41:45.646', endDate: '2025-02-21T12:41:44.646', isMilestone: false, percentCompleted: null, dependency: '', status: { enumKey: 2, id: 30, name: 'Planned', }, pilot: { amei: '1088448', id: 2, name: 'Niels VAN GOETHEM 2', }, concurrency: 'AAAAAAAEb6s=', resources: [ { id: 1, resourceType: 1, employee: { amei: '1088448', id: 2, name: 'Niels VAN GOETHEM', }, function: null, }, { id: 2, resourceType: 1, employee: { amei: '518345', id: 1, name: 'KINGSLEY NESEN', }, function: null, }, { id: 3, resourceType: 2, employee: null, function: { id: 1, name: 'Developer', }, }, ], }, { id: 19, parentId: null, title: 'New Task 3', description: 'To be added later?', startDate: '2024-11-20T12:41:45.646', endDate: '2024-11-20T12:41:45.646', isMilestone: true, percentCompleted: null, dependency: '', status: { enumKey: 2, id: 30, name: 'Planned', }, pilot: { amei: '1088448', id: 3, name: 'Niels VAN GOETHEM 3', }, concurrency: 'AAAAAAAEb6w=', resources: [], }, ]; |
Modified Sample - https://stackblitz.com/edit/angular-sfljjh-jlngso?file=src%2Fapp.component.html,src%2Fapp.component.ts,src%2Fdata.ts
Regards,
Sridharan
- 5 Replies
- 3 Participants
- Marked answer
-
NV Niels Van Goethem
- Nov 26, 2024 12:55 PM UTC
- Nov 29, 2024 03:29 PM UTC