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 GetCustomers()
{
List<Customer> customers = new List<Customer>();
customers.Add(new Customer { CustomerId = 1, Name = "John Hammond", Date = DateTime.Now });
customers.Add(new Customer { CustomerId = 2, Name = "Mudassar Khan", Date = DateTime.Now.AddDays(-1) });
customers.Add(new Customer { CustomerId = 3, Name = "Suzanne Mathews", Date = DateTime.Now.AddMonths(-1) });
customers.Add(new Customer { CustomerId = 4, Name = "Robert Schidner", Date = DateTime.Now.AddYears(-1) });
return Json(customers, JsonRequestBehavior.AllowGet);
}
public class Customer
{
public int CustomerId { get; set; }
public string Name { get; set; }
public DateTime Date { get; set; }
}
}
View
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<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>
<script type="text/javascript">
var app = angular.module("MyApp", ["kendo.directives"]);
app.controller("MyController", function ($scope) {
$scope.mainGridOptions = {
dataSource: { transport: { read: "/Home/GetCustomers/" }, pageSize: 5 },
pageable: { refresh: true, pageSizes: [2, 25, 50] },
groupable: false,
sortable: true,
columns: [
{ field: "CustomerId", title: "Id", width: 40 },
{ field: "Name", title: "Name", width: 150 },
{
title: "Date",
template: '<input id="txtDate" width="50px" />'
}
],
dataBound: function (e) {
var grid = e.sender;
var items = e.sender.items();
items.each(function (e) {
var dataItem = grid.dataItem(this);
var txtDate = $(this).find('#txtDate');
$(txtDate).kendoDateInput({
value: new Date(ConvertJsonDateToDateTime(dataItem.Date)),
format: "dd/MM/yyyy"
});
});
}
}
function ConvertJsonDateToDateTime(date) {
var parsedDate = new Date(parseInt(date.substr(6)));
var newDate = new Date(parsedDate);
var month = newDate.getMonth() + 1;
var day = newDate.getDate();
var year = newDate.getFullYear();
return day + "/" + month + "/" + year;
}
});
</script>
</head>
<body ng-app="MyApp" ng-controller="MyController">
<kendo-grid k-options="mainGridOptions" id="tblGrid"></kendo-grid>
</body>
</html>
Screenshot