Hi friends,
I follow the guide to edit a gantt control. Server code receives items changed by batchUrl correctly. But when it's processed and return the changed items then the gantt control always show spinner load image. Debugging browser can view this error: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'replace').
Could you help me?
DataManager:
<e-data-manager url="/Gantt/Datasource/?ganttType=@Context.Request.Query["gantttype"]&id=@Context.Request.Query["id"]" adaptor="UrlAdaptor" batchUrl="/Gantt/BatchUpdate/?ganttType=@Context.Request.Query["gantttype"]&id=@Context.Request.Query["id"]"></e-data-manager>
Code behind:
public async Task<IActionResult> BatchUpdate([FromBody] ICRUDModel<Gantt> data, GanttType ganttType, int id)
{
List<Gantt> uChanged = new List<Gantt>();
if (data.Changed != null && data.Changed.Count() > 0)
{
foreach (var rec in data.Changed)
{
var task = await _context.Tasks.FindAsync(rec.taskId);
if (task != null)
{
// Update task fields
}
uChanged.Add(rec);
}
}
return Json(new { changedRecords = uChanged });
}
Hi Jesus ,
This issue occurs because editing requires a primary key column. By default, the TaskId column will be the primary key column. You can avoid this by either setting the visibility of the TaskId column as false or you can set another column as the primary key column by mapping the IsPrimaryKey field to another column. By doing this, you do not have to map the TaskId column. For more details, please refer to our Online Documentation.
Code snippets:
<e-gantt-columns> <e-gantt-column field="TaskId" visible= “false”></e-gantt-column> <e-gantt-column field="TaskName" headerText="Name" width="250"></e-gantt-column> <e-gantt-column field="Progress"></e-gantt-column> <e-gantt-column field="StartDate"></e-gantt-column> <e-gantt-column field="Duration"></e-gantt-column> </e-gantt-columns> |
Online documentation: https://ej2.syncfusion.com/aspnetcore/documentation/gantt/managing-tasks#troubleshoot-editing-works-only-when-primary-key-column-is-defined
Regards,
Premkumar S
Thanks Premkumar, very helpful
Hi Jesus,
Most welcome. Please get back to us if you need any further assistance.
Regards,
Ranjani
Really helpful, im on React and it instantanely resolved my problem, you're a boss