We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Get JS ej2.min.js Cannot read properties of undefined (reading 'replace') on Editing Gantt

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 });
        }

4 Replies

PS Premkumar Sudalaimuthu Syncfusion Team June 14, 2022 10:00 AM UTC

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



JM Jesús Mostajo June 14, 2022 05:10 PM UTC

Thanks Premkumar, very helpful



RP Ranjani Prabakaran Syncfusion Team June 15, 2022 04:51 AM UTC

Hi Jesus,


Most welcome. Please get back to us if you need any further assistance.


Regards,


Ranjani



DT dev techw June 21, 2023 01:13 PM UTC

Really helpful, im on React and it instantanely resolved my problem, you're a boss


Loader.
Up arrow icon