Hi rani,
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 GetCustomers()
{
List<Customer> customers = new List<Customer>();
customers.Add(new Customer { CustomerId = 1, Name = "John Hammond", Country = "United States" });
customers.Add(new Customer { CustomerId = 2, Name = "Mudassar Khan", Country = "India" });
customers.Add(new Customer { CustomerId = 3, Name = "Suzanne Mathews", Country = "France" });
customers.Add(new Customer { CustomerId = 4, Name = "Robert Schidner", Country = "France" });
return Json(customers, JsonRequestBehavior.AllowGet);
}
}
public class Customer
{
public int CustomerId { get; set; }
public string Name { get; set; }
public string Country { get; set; }
}
View
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Index</title>
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2020.1.114/styles/kendo.default-v2.min.css" />
<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script type="text/javascript" src="https://kendo.cdn.telerik.com/2020.1.114/js/angular.min.js"></script>
<script type="text/javascript" src="https://kendo.cdn.telerik.com/2020.1.114/js/kendo.all.min.js"></script>
<style type="text/css">
body
{
font-family: Arial;
font-size: 12pt;
}
</style>
<script type="text/javascript">
var app = angular.module("MyApp", ["kendo.directives"]);
app.controller("MyController", function ($scope, $window, $http) {
$scope.mainGridOptions = {
dataSource: { transport: { read: "/Home/GetCustomers/" }, pageSize: 2 },
pageable: { refresh: true, pageSizes: [2, 25, 50] },
groupable: false,
sortable: true,
selectable: "row",
change: function () {
var row = this.select();
var dataItem = this.dataItem(row);
alert("Id : " + dataItem.CustomerId + "\nName : " + dataItem.Name + "\nCountry : " + dataItem.Country);
},
columns: [
{ field: "CustomerId", title: "Id" },
{ field: "Name", title: "Name" },
{ field: "Country", title: "Country" }
]
};
})
</script>
</head>
<body ng-app="MyApp" ng-controller="MyController">
<kendo-grid options="mainGridOptions"></kendo-grid>
</body>
</html>
Screenshot