@{
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) {
GetCountries();
$scope.mainGridOptions = {
dataSource: {
transport: {
read: { url: "/Home/GetCustomers" },
update: {
url: "/Home/UpdateCustomer",
type: 'POST'
}
},
schema: {
model: {
id: "Id",
fields: {
Id: { editable: false, nullable: true, type: "number" },
Name: { editable: true, nullable: true, type: "string" },
countries: { editable: true, nullable: true, type: "object" }
}
}
},
pageSize: 4,
serverPaging: true,
serverSorting: true
},
editable: "inline",
sortable: true,
pageable: true,
resizeable: true,
columns: [
{ field: "Id", title: "Id", width: "70px" },
{ field: "Name", title: "Name", width: "150px" },
{
title: "Country",
field: "countries",
width: "200px",
template: "#= CountryName(countries) #",
editor: function (container) {
var input = $('<input id="countries" name="countries" />');
input.appendTo(container);
input.kendoMultiSelect({
optionLabel: "Select Country",
dataTextField: "Name",
dataValueField: "CountryId",
filter: "contains",
minLength: 2,
dataSource: Countries,
headerTemplate: '<label><input type="checkbox" id="selectAll"> Select All</label>',
itemTemplate: "<input type='checkbox'/> #:data.Name#",
change: function (e) {
var totalItems = this.dataSource.data().length;
var selected = this.value().length;
if (totalItems != selected) {
$('#selectAll').prop('checked', false);
}
else {
$('#selectAll').prop('checked', true);
}
},
autoClose: false
}).appendTo(container);
}
},
{
title: 'Action',
command: [{ name: "edit", text: "Edit", iconClass: "k-icon k-i-hyperlink-open" }]
}
]
};
})
var Countries = [];
function GetCountries() {
$.ajax({
method: 'Get',
url: '/Home/GetCountryName',
}).success(function (data) {
Countries = data;
}).error(function (response) {
alert(response.responseText);
});
}
function CountryName(countries) {
if (countries != null) {
return Array.prototype.map.call(countries, function (item) {
if (item != null) {
return item.Name;
}
}).join(",");
}
}
$(document).ready(function () {
$('#selectAll').change(function () {
var multiSelect = $("#countries").data("kendoMultiSelect");
if ($(this).prop('checked')) {
selectAll();
}
else {
multiSelect.value(null);
}
});
});
function selectAll() {
var multiselect = $("#countries").data("kendoMultiSelect");
var selectedValues = [];
for (var i = 0; i < multiselect.dataSource.data().length; i++) {
var item = multiselect.dataSource.data()[i];
selectedValues.push(item.value);
}
multiselect.value(selectedValues);
//multiSelect.trigger("change");
multiselect.close();
}
</script>
</head>
<body ng-app="MyApp" ng-controller="MyController">
<kendo-grid k-options="mainGridOptions" id="tblCustomers"></kendo-grid>
</body>
</html>
This is what i tried from my end select all is not working can you please help me out