Hi,
my requirement is that after clicking of edit button based upon Id value display relevant values on multiselect checkbox
@{
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="~/scripts/angular.js"></script>
<script type="text/javascript" src="~/scripts/angular.js"></script>
<script src="~/scripts/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/UpdateCustomers" },
},
pageSize: 2,
schema: {
model: {
id: "Id",
fields: {
QId: { editable: false, nullable: true, type: "number" },
QName: { editable: true, nullable: true, type: "string" },
CountryId: { editable: true, nullable: true, type: "number" },
}
}
},
serverPaging: true,
serverSorting: true
},
editable: "inline",
sortable: true,
pageable: true,
resizeable: true,
columns: [
{ field: "Id", title: "Id", width: "50px" },
{
field: "Name", title: "Name"
},
{
title: "Country",
field: "countries",
width: "200px",
template: "#=CountryName(countries) #",
editor: function (container) {
var input = $('<input id="CountryId" name="CountryId" />');
input.appendTo(container);
input.kendoMultiSelect({
optionLabel: "Select Country",
dataTextField: "Name",
dataValueField: "CountryId",
filter: "contains",
minLength: 2,
dataSource: Countries,
dataBound: function () {
var items = this.ul.find("li");
setTimeout(function () {
//checkInputs(items);
});
},
itemTemplate: "<input type='checkbox'/> #:data.Name#",
headerTemplate: "<div><input type='checkbox' id='Header'><label> Select All</label></div>",
autoClose: false,
change: function () {
var items = this.ul.find("li");
//checkInputs(items);
}
}).appendTo(container);
}
},
{
title: 'Action',
command: [{ name: "edit", text: "Edit", iconClass: "k-icon k-i-hyperlink-open" }]
}
],
edit: function (e) {
}
};
GetCountries();
})
var Countries = [];
function GetCountries() {
$.ajax({
method: 'Get',
url: '/Home/GetCountryName',
}).success(function (data, status, headers, config) {
Countries = data;
}).error(function (data, status, headers, config) {
message = 'Unexpected Error';
});
}
function CountryName(countries) {
return Array.prototype.map.call(countries, function (item) { return item.Name; }).join(",")
}
</script>
</head>
<body ng-app="MyApp" ng-controller="MyController">
<kendo-grid k-options="mainGridOptions"></kendo-grid>
</body>
</html>
public class Customer
{
public int Id { get; set; }
public string Name { get; set; }
public List<Country> countries { get; set; }
}
countries are binding based upon Id value
public class Country
{
public int CountryId { get; set; }
public string Name { get; set; }
public int Id { get; set; }
}
can you please help me