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

EJS Grid duplicate rows after insert

When executing add method on the grid the row is properly added to the system, new row shows up in the grid, but also one additional row is added - only in the view itself because the JSON data behind doesn't have this row.  Then changing the grid order duplicate this empty row. 
Scenario:
1. one funky grid 

2. lets add record 
3. dafuq is this?

4. oh no!

5. please stop!

6. Can't even delete it! 

Doesn't matter if  I  return an added object (grid displays it properly) or null, the additional empty row is always added. 

How to solve this? 

and check this not working url :)  https://ej2.syncfusion.com/aspnetmvc/documentation/grid/global-and-local


 @(Html.EJS().Grid("TestGrid")
                .DataSource(dataManager => 
{ dataManager.Json(Model.Workers.ToArray())
             .InsertUrl(@Url.Action("Insert", ""))
     .UpdateUrl(@Url.Action("Update", ""))
      .RemoveUrl(@Url.Action("Delete", ""))
      .Adaptor("RemoteSaveAdaptor"); 
                                  })                                                                                                                                                                         
                .Columns(col =>
                   {
                       col.Field(nameof(PlannedTime.Id)).HeaderText("Id").Width("0").Visible(false)
     .IsIdentity(true).IsPrimaryKey(true).AllowEditing(false).ShowInColumnChooser(false).Add();
                       col.Field(nameof(PlannedTime.Comment)).HeaderText("Test").Width("200").Add();
                      })
                .EditSettings(edit => 
{ edit.AllowAdding(true).AllowEditing(true).AllowDeleting(true).ShowDeleteConfirmDialog(true)
      .AllowEditOnDblClick(false).Mode(Syncfusion.EJ2.Grids.EditMode.Dialog); })
                .Toolbar(new List() 
{ "Add", "Edit", "Delete", "Update", "Cancel","ExcelExport" }).ToolbarClick("toolbarClick")
                .AllowExcelExport().AllowSorting(true).AllowSelection(true)
                .Render()
        )


7 Replies

MF Mohammed Farook J Syncfusion Team November 23, 2018 12:22 PM UTC

Hi Kamil, 
 
Thanks for contacting Syncfusion support. 
 
We have validated and tried to reproduce the reported issue but it was unsuccessful. So please find the code example and sample for your reference. 
 
 
Code example 
 
[index.cshtml] 
 
  @Html.EJS().Grid("Grid").ActionBegin("actionBegin").DataSource(dataManager =>{dataManager.Json(ViewBag.dataSource).InsertUrl("/Home/Insert").RemoveUrl("/Home/Delete").UpdateUrl("/Home/Update").Adaptor("RemoteSaveAdaptor"); 
}).EditSettings(edit => 
{ 
    edit.AllowAdding(true).AllowEditing(true).AllowDeleting(true).ShowDeleteConfirmDialog(true) 
        .AllowEditOnDblClick(false).Mode(Syncfusion.EJ2.Grids.EditMode.Dialog); 
}).Columns(col => 
{ 
    col.Field("OrderID").HeaderText("Order ID").Visible(false).IsIdentity(true).IsPrimaryKey(true).Width("30%").Add(); 
    col.Field("EmployeeID").HeaderText("Employee ID").Width("150").Add(); 
    col.Field("CustomerID").HeaderText("CustomerID").Width("70").Add(); 
 
}).AllowPaging().Toolbar(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" }).Render() 
 
</div> 
 
<script> 
    var PkValue = 1000; 
 
    function actionBegin(args) { 
    
        if (args.requestType == 'save' && args.action == 'add') { 
            args.data[this.getPrimaryKeyFieldNames()[0]] = ++PkValue; 
        } 
    } 
</script> 
 
 
[controller] 
 
public ActionResult Index() 
        { 
            ViewBag.dataSource = OrdersDetails.GetAllRecords().ToArray(); 
            return View(); 
        } 
 
        public ActionResult Update(OrdersDetails value) 
        { 
            var ord = value; 
            OrdersDetails val = OrdersDetails.GetAllRecords().Where(or => or.OrderID == ord.OrderID).FirstOrDefault(); 
            val.OrderID = ord.OrderID; 
            val.EmployeeID = ord.EmployeeID; 
            val.CustomerID = ord.CustomerID; 
            return Json(value); 
        } 
        //insert the record 
        public ActionResult Insert(OrdersDetails value) 
        { 
 
            OrdersDetails.GetAllRecords().Insert(0, value); 
            return Json(new { data = value }); 
        } 
        //Delete the record 
        public ActionResult Delete(int key) 
        { 
            OrdersDetails.GetAllRecords().Remove(OrdersDetails.GetAllRecords().Where(or => or.OrderID == key).FirstOrDefault()); 
            var data = OrdersDetails.GetAllRecords(); 
            return Json(data); 
        } 
 
  . . .  
 
} 
 
 
 
 
Please ensure your application has return data properly in add method at server side. Please find the screenshot for your reference. 
 
 
addRecord at server side 
 
 
 
 
data at response 
 
 
 
 
 
Note: Grid can bind the data what did you return from server while using CRUD action with DataAdaptors. 
 
 
Still if you have faced same issue again , could you please share following details 
 
  • Please share the EJ2 version details
 
  • Please share the full grid code example
 
  • Please share the response of network tab of your browser
 
  • Please share the sample if it is possible
 
 
 
Regards, 
J Mohammed Farook 



KA Kamil November 23, 2018 01:15 PM UTC

I have reproduced the issue with your example project. 
Just change reference to:    src="https://cdn.syncfusion.com/ej2/dist/ej2.min.js"



MF Mohammed Farook J Syncfusion Team November 26, 2018 11:31 AM UTC

Hi Kamil, 
 
We have validated the reported issue and we are able to reproduce the issue. So We have considered the “RemoteSaveAdaptor returns empty row while perform adding in Grid” ” as an issue and logged a report for the same. This fix will be available  on December 05, 2018 patch release. 
 
Until then we appreciate your patience. 
 
 
Regards, 
J Mohammed Farook 



KA Kamil December 14, 2018 09:01 AM UTC

I just checked the new 16.4.40-beta version and the issue is not fixed :(


MF Mohammed Farook J Syncfusion Team December 14, 2018 10:52 AM UTC

 
Hi Kamil,  
 
Sorry for the inconvenience cost, due to the complexity of the issue “RemoteSaveAdaptor returns empty row while perform adding in Grid” we are not able to include the fix in the Volume 4, 2018 Beta release. We will include the fix in our next patch release. Which will be available at the first week of January 2019. Until then we appreciate your patience. 
Regards, 
J Mohammed Farook 



TA TAC January 28, 2019 02:48 AM UTC

It's now end of January 2019. Has this issue been resolved? Solution path appreciated


PS Pavithra Subramaniyam Syncfusion Team January 28, 2019 06:38 AM UTC

Hi Kamil, 
 
Thanks for your patience. 
 
We are glad to announce that the issue “To provide support for handling whole dataset in ODataV4 with Batch editing” has been fixed and this fix is now available in our latest Essential JavaScript 2 package(v16.4.48). So please upgrade Essential JavaScript 2 package and use our latest source in your application. 
 
Regards, 
Pavithra S. 


Loader.
Up arrow icon