Reputation: 323
I have a requirement in which I have to restrict the max selection of rows in Kendo grid to 5, user can select max 5 records in Kendo grid. Any body have any idea or sample code.
Your help will be appreciated.
Thanks.
Upvotes: 2
Views: 786
Reputation: 18202
Kendo doesn't have an out of the box support for max selected rows. Use the Change
event to catch an array of selected rows and de-select extra rows. The basic working code is as follows where the user can select 5 rows at max.
$("#grid").kendoGrid({
change: function(e) {
var items = e.sender.select();
items.each(function(i, e) {
/* allows user to select 5 rows max */
if (i > 4) {
$(e).removeClass("k-state-selected");
}
});
}
});
Check out the demo fiddle.
Upvotes: 0