Hi mahesh213,
Check this example. Now please take its reference and correct your code.
Controller
public class HomeController : Controller
{
// GET: /Home/
public ActionResult Index()
{
return View();
}
public JsonResult GetAll()
{
List<Customer> customers = new List<Customer>();
customers.Add(new Customer { Id = 1, Name = "Category 1", IsEmployee = 1 });
customers.Add(new Customer { Id = 2, Name = "Category 2", IsEmployee = 0 });
customers.Add(new Customer { Id = 3, Name = "Category 3", IsEmployee = 1 });
return Json(customers, JsonRequestBehavior.AllowGet);
}
}
public class Customer
{
public int Id { get; set; }
public string Name { get; set; }
public int IsEmployee { get; set; }
}
View
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Index</title>
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2016.3.1028/styles/kendo.common.min.css" />
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2016.3.1028/styles/kendo.rtl.min.css" />
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2016.3.1028/styles/kendo.silver.min.css" />
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2016.3.1028/styles/kendo.mobile.all.min.css" />
<script type="text/javascript" src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script type="text/javascript" src="https://kendo.cdn.telerik.com/2016.3.1028/js/kendo.all.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#grid").kendoGrid({
dataSource: {
transport: {
read: "/Home/GetAll/"
},
pageSize: 20
}, pageable: {
refresh: true,
pageSizes: [2, 25, 50]
},
height: 550,
groupable: true,
sortable: true,
columns: [{
field: "Id",
title: "Id",
width: "10%"
}, {
field: "Name",
title: "Name",
width: "15%"
}, {
field: "Is Active",
template: "#if(IsEmployee == 0) {#<div><input type='checkbox' onclick='onChange(this)' id='target' ></div>#}if(IsEmployee == 1) {#<div><input type='checkbox' onclick='onChange(this)' id='target' checked></div>#}if(IsEmployee ==null) {#<div><input onclick='onChange(this)' type='checkbox' id='target'></div>#}#"
}]
});
});
function onChange(ele) {
var id = $(ele).closest('tr').find('td').eq(0).html().trim();
var isChecked = $(ele).is(":checked");
alert("Id : " + id + "\nChecked : " + isChecked);
// Make Ajax call to ActionResult and update the checkbox value.
}
</script>
</head>
<body>
<div id="example">
<div id="grid"></div>
</div>
</body>
</html>
Screenshot