Hi,
after clicking of edit button once i made any changes on salary the updated values are not coming to controller.
can you please help me .
@{
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, $window, $http) {
$scope.mainGridOptions = {
dataSource: {
type: "json",
transport: {
read: { url: "/Home/GetCustomers" },
update: { url: "/Home/UpdateCustomer" }
},
schema: {
model: {
id: "Id",
fields: {
CustomerId: { editable: false, nullable: true, type: "number" },
Name: { editable: true, nullable: true, type: "string" },
Country: { editable: true, nullable: true, type: "string" }
}
}
},
pageSize: 2,
serverPaging: false,
serverSorting: false
},
editable: "inline",
sortable: true,
pageable: true,
resizeable: true,
columns: [
{ field: "Id", title: "Id", width: "50px" },
{ field: "Name", title: "Name" },
{ field: "Country", title: "Country" },
{field:"Salary",title:"Salary"}.
{
title: 'Action',
command: [{ name: "edit", text: "Edit", iconClass: "k-icon k-i-hyperlink-open" }]
}
],
edit: function (e) {
var container = e.container;
var txtName = container.find("input[name=Name]");
$(txtName).hide();
}
};
})
$(function () {
$('body').on('keyup', "input[name=Salary]", function () {
$(this).val(numberWithCommas(parseFloat($(this).val().replace(/,/g, ""))));
});
});
function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
</script>
</head>
<body ng-app="MyApp" ng-controller="MyController">
<kendo-grid k-options="mainGridOptions"></kendo-grid>
</body>
</html>
public JsonResult GetCustomers()
{
List<Customer> customers = new List<Customer>();
customers.Add(new Customer { Id = 1, Name = "John Hammond", Country = "United States" ,Salary="2000"});
customers.Add(new Customer { Id = 2, Name = "Mudassar Khan", Country = "India" , Salary = "2000" });
customers.Add(new Customer { Id = 3, Name = "Suzanne Mathews", Country = "France" , Salary = "2000" });
customers.Add(new Customer { Id = 4, Name = "Robert Schidner", Country = "Russia", Salary = "2000" });
return Json(customers, JsonRequestBehavior.AllowGet);
}
public JsonResult UpdateCustomer(Customer customer)
{
return Json(customer, JsonRequestBehavior.AllowGet);
}
public class Customer
{
public int Id { get; set; }
public string Name { get; set; }
public string Country { get; set; }
public string Salary { get; set; }
}