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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Preventing some records to be edited/deleted

Thread ID:





141900 Jan 9,2019 09:20 PM UTC Jan 10,2019 04:30 AM UTC ASP.NET MVC - EJ 2 1
Tags: Grid
Asked On January 9, 2019 09:20 PM UTC


Using EJ2, MVC5, VS2017, MySql, EF6

I´d like to be able to check records before editing or deleting them. Let´s say a record has a "satus" field where I must check its value and depending on that value (0, 1, etc) it can be edited or deleted, otherwise if its value is i.e. 3 it cannot be changed or deleted. 

Please, note I am using Razor, MVC5, EF6...

Is there a way to do it?

Thank you!

Pavithra Subramaniyam [Syncfusion]
Replied On January 10, 2019 04:30 AM UTC

Hi Vanderlei, 
Thanks for contacting Syncfusion support. 
You can achieve your requirement by enabling the args.cancel property in the ‘actionBegin’ event with requestType “beginEdit” and “delete”. Please refer to the below code example and documentation link for further information. 
In the below demo, the rows which are having the value for ShipCountry column as “Denmark” is prevented from editing. 
@Html.EJS().Grid("Grid").DataSource((IEnumerable<object>)ViewBag.DataSource).AllowPaging().Columns(col => 
        col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).Width(30).Add(); 
        col.Field("CustomerID").HeaderText("Customer ID").Width(30).Add(); 
        col.Field("ShipCity").HeaderText("Ship City").Width(30).Add(); 
        col.Field("ShipCountry").HeaderText("Ship Country").Width(30).Add(); 
    }).EditSettings(edit => { edit.AllowAdding(true).AllowEditing(true).AllowDeleting(true).Mode(Syncfusion.EJ2.Grids.EditMode.Dialog); }).Toolbar(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" }).ActionBegin("actionBegin").Render() 
    function actionBegin(args) { 
        if (args.requestType === "beginEdit" || args.requestType === "delete") { 
            // you can check your required condition here 
            var data = args.rowData ? args.rowData : args.data[0]; 
            if (data.ShipCountry == "Denmark") {  
                args.cancel = true; 
Pavithra S. 


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

Live Chat Icon For mobile
Live Chat Icon