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

Make certain cells in a grid row read only based on the value of a cell in the row

Thread ID:

Created:

Updated:

Platform:

Replies:

126212 Sep 30,2016 05:18 PM Oct 3,2016 08:14 AM ASP.NET MVC 1
loading
Tags: Grid
Jason Black
Asked On September 30, 2016 05:18 PM

I'm trying make certain cells in a grid row read only(non editable) based on the value of a cell in that row.  I'm using the following script and it seems to set the property to true but it still allows me to edit those cells.

function RowDataBound(args)
{
    var IsHostRep = args.data["IsHost"];
    var currentrow = args.model.currentIndex;
    if (args.data.IsHost == 1)
    {
        args.row[currentrow].cells[1].disabled = true;
    }
}

Prasanna Kumar Viswanathan [Syncfusion]
Replied On October 3, 2016 08:14 AM

Hi Jason, 
  
Thanks for contacting Syncfusion support. 
  
To make a cell non-editable based on its value, use actionComplete event of ejGrid. The actionComplete event triggered for every grid action success event. In actionComplete event, we check the condition with the requestType and disable the EmployeeID cell by adding disabled attribute and disable class when it has a value of 5. 
  
Find the code example and sample: 
  
  
@(Html.EJ().Grid<object>("FlatGrid") 
       .Datasource((IEnumerable<object>)ViewBag.datasource) 
       .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); }) 
       .AllowPaging() 
       .ToolbarSettings(toolbar => 
         { 
           toolbar.ShowToolbar().ToolbarItems(items => 
             { 
               items.AddTool(ToolBarItems.Add); 
               items.AddTool(ToolBarItems.Edit); 
               items.AddTool(ToolBarItems.Delete); 
               items.AddTool(ToolBarItems.Update); 
               items.AddTool(ToolBarItems.Cancel); 
             }); 
         }) 
       .Columns(col => 
        { 
          --------------------------- 
        }) 
       .ClientSideEvents(eve => { eve.BeginEdit("beginEdit"); }) 
    ) 
  
<script> 
    function beginEdit(args) { 
if(args.requestType == "beginedit") { 
        var data = args.row.find("input"); 
        for (var i = 0 ; i < data.length ; i++) { 
            if (data[i].name == "EmployeeID" && parseInt($(data[i]).attr("value")) == 5) { 
                $(data[i]).addClass("e-disable").attr("disabled","disabled"); 
            } 
        } 
      }    } 
</script> 
  
  
  
Refer to the Help document for the actionComplete event. 
  
  
Regards, 
Prasanna Kumar N.S.V 
 


CONFIRMATION

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.

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.

;