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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Delete row using build-in toolbar. But remove wrong row in datasource

Thread ID:





128246 Jan 10,2017 06:11 PM UTC Jan 11,2017 12:38 PM UTC ASP.NET MVC 2
Tags: Grid
Steve Lei
Asked On January 10, 2017 06:11 PM UTC


When I trying to delete row in grid using build-in toolbar, the deletion display is correct. However, when I try get the datasource in jQuery, it seems remove wrong row in datasource.

For example, the product grid shows 2 products. If I delete 1st item, the display and datasource are sync. correctly. But if I delete 2nd item. The display is correct, but datasource is showing 1st itme data.

Here is how I get the datasource object in jQuery

var products = $("#InvoiceProducts").ejGrid("option", "dataSource");

I am using this is because I have save button for entire form. The controller will get all updated data and determine which row need to insert/update or delete.
Does additional call to make grid sync with datasource after deletion?

Attached is the screenshot document to explain more clearly.


Attachment: Syncfusion_Grid_Deletion_f49c6ded.zip

Steve Lei
Replied On January 10, 2017 06:29 PM UTC

I think I may find out why delete the wrong one. I have to set the primarykey field to true.

@(Html.EJ().Grid<InvoiceProductServices>("InvoiceProducts").Datasource((IEnumerable<object>) Model.InvoiceProducts)
                                  .TextWrapSettings(wrap => { wrap.WrapMode(WrapMode.Both); })
                                  .EditSettings(edit => { edit.AllowDeleting().AllowEditing().ShowDeleteConfirmDialog(); })
                                  .ToolbarSettings(toolbar =>
                                      toolbar.ShowToolbar().ToolbarItems(items =>
                                  .Columns(col =>
                                      col.Field("ModelNumber").HeaderText("Model Number").Width(130).Add();

Mani Sankar Durai [Syncfusion]
Replied On January 11, 2017 12:38 PM UTC

Hi Steve,  

Thanks for contacting Syncfusion support. 

Yes the primary key for the data source should be defined in Columns definition, for editing to work properly by enabling IsPrimaryKey property of columns in grid. We have already discussed about this in the following KB.  
Refer to the Help Documents and API Reference Section of the Grid.  
Also we have already documented about the necessity of IsPrimaryKey property of columns in the Editing section of the below document link.  
Please let us know if you need further assistance. 
Manisankar Durai 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon