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
close icon

Js error when trying to perform server delete

I get the js error when I'm trying to delete object listed on the grid.
The error message displayed in Firefox console is "TypeError: r is null   ej.web.all.min.js:10:36786"

This is how I setup the grid:

@(Html.EJ().Grid<TransactionViewModel>("transactionsGrid")
        .Datasource(ds => ds.Json(Model).RemoveURL("/Expenses/Remove").Adaptor(AdaptorType.RemoteSaveAdaptor))
        .IsResponsive(true).EditSettings(e =>
          {
              e.AllowDeleting();
          }).ToolbarSettings(t => t.ShowToolbar().ToolbarItems(i =>
          {
              i.AddTool(ToolBarItems.Delete);
          }))
          .Columns(col =>
          {

              col.Field(p => p.Expense.Date).Format("{0:dd-MM-yyyy}").HeaderText(ResourcesDataProvider.GetStringFromResourceFile(Strings.Date)).Width("100").Add();
              col.Field(p => p.Expense.Goal).HeaderText(ResourcesDataProvider.GetStringFromResourceFile(Strings.Goal)).Width("200").Add();
              col.Field(p => p.Expense.Value).HeaderText(ResourcesDataProvider.GetStringFromResourceFile(Strings.Value)).Width("150").Add();
              col.Field(p => p.PayerName).HeaderText(ResourcesDataProvider.GetStringFromResourceFile(Strings.UserName)).Width("200").Add();
              col.Field(p => p.Expense.Description).HeaderText(ResourcesDataProvider.GetStringFromResourceFile(Strings.Description)).Add();
          }))



1 Reply

PK Prasanna Kumar Viswanathan Syncfusion Team March 27, 2017 08:53 AM UTC

Hi Michal, 

Thanks for contacting Syncfusion support. 

In your code example we found that you have not set PrimaryKey field in Grid Columns which is the cause of the issue. While performing delete operation we delete the record using primarykey. In order to resolve the issue, set “isPrimaryKey” property to the Primary key column. 
 
Find the code example:  
 
 
.Columns(col => 
     { 
         col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(100).ValidationRules(v => v.AddRule("required", true).AddRule("minlength", 3)).Add(); 
         col.Field("CustomerID").HeaderText("Customer ID").TextAlign(TextAlign.Right).Width(90).Add(); 
         -------------------------- 
    }) 

Regards, 
Prasanna Kumar N.S.V 


Loader.
Live Chat Icon For mobile
Up arrow icon