Hello,
I am writing to inquire about finding a way to handle errors for the Gantt Chart component.
Prerequisites:
The DataSource is based on a Data Manager.
I have two scenarios:
Addition using the toolbar 'Add' button:
I have tried intercepting backend errors using the actionFailure event, but there is one small problem. Even though the backend returns a 400 HTTP code and an error message, the actionFailure event doesn't contain the error message.
Resizing bars - Batch Update:
How can I intercept and display an error message during a batch update? I receive information regarding the error in the request response, but I want to display it to the user. Furthermore, the resizing of a line should be undone in case of an error, and it isn't.
Best regards
Jacek
Hi Jacek,
Greetings from Syncfusion Support.
We want to inform you that we are currently working on resolving the issue you reported as a matter of great urgency. We assure you that we are dedicating significant resources to resolve this promptly. We expect to provide you with an update on or before December 29, 2023.
Thank you for your patience and understanding.
Regards,
Ajithkumar G
Hi Jacek,
We appreciate your patience.
Query#1: I have tried intercepting backend errors using the actionFailure event, but there is one small problem. Even though the backend returns a 400 HTTP code and an error message, the actionFailure event doesn't contain the error message.
With the assistance of the actionFailure event argument, we can effectively display error messages thrown from the server. This event provides a mechanism to capture and handle errors in client side. The code snippet used below prints a message in the console tab. We are manually throwing an exception from the server side.
|
function actionFailure(args) {
args.error[0].error.text().then(text => { console.log(text);
}) } |
Query#2: How can I intercept and display an error message during a batch
update? I receive information regarding the error in the request response, but
I want to display it to the user. Furthermore, the resizing of a line should be
undone in case of an error, and it isn't.
Upon editing the taskbar post a batch update call, an exception
is deliberately triggered based on a condition. While attempting to edit any
record the taskbarEditing event will be triggered,
during that time the record is backed up locally. If the manual exception
occurs, the actionFailure event
is triggered, prompting data restoration using the updateRecordById method
for seamless recovery.
|
public IActionResult BatchUpdate([FromBody] CRUDModel batchmodel) { … if (batchmodel.Added != null) {
if (batchmodel.Added[0] != null) { Response.StatusCode = 500; return Json(new { Message = "There is a problem in LoadData method",success=false }); } for (var i = 0; i < batchmodel.Added.Count(); i++) { DataList.Insert(0, batchmodel.Added[i]); }
} if (batchmodel.Changed[0] != null && batchmodel.Changed[0].taskId == 3 && batchmodel.Changed[0].duration == "5") { Response.StatusCode = 500; return Json(new { Message = "There is a problem in LoadData method", success = false }); } return Json(new { addedRecords = batchmodel.Added, changedRecords = batchmodel.Changed, deletedRecords = batchmodel.Deleted }); } catch (Exception ex) { // Return the exception message in the response return StatusCode(500, new { error = ex.Message }); } } |
|
function taskbarEditing(args) { if (!isEditInprogress) { editedRecord = JSON.parse(JSON.stringify(args.data)); isEditInprogress = true } } function actionFailure(args) { this.ganttObj.updateRecordByID(this.editedRecord); |
Sample link: https://stackblitz.com/edit/angular-zxsb9r-tmqgqg?file=src%2Fapp.component.ts,src%2Fapp.component.html
Web service: https://www.syncfusion.com/downloads/support/directtrac/general/ze/web-service2022119016.zip
If you have any specific concerns or encounter issues, please provide additional
details or share a sample that replicates the problem. We are here to assist
you further.
Regards,
Ajithkumar G