I'm using a checkbox instead, and here is how I am defining it.
columns.Bound(x => x.IsChecked).ClientTemplate(
"<input name='IsChecked' class='chkBox' type='checkbox'
data-bind='checked: IsChecked' #= IsChecked ? checked='checked' : '' #/>");
And then on click function of the grid
$('#Grid').click(function () {
var gview = $("#Grid").data("kendoGrid");
var selectedItem = gview.dataItem(gview.select());
var bool = selectedItem.IsChecked;
selectedItem.set("IsChecked", (bool) ? 0 : 1);
console.log(selectedItem);
gview.tbody.find("tr[data-uid='" + selectedItem.uid + "']")
.addClass("k-state-selected");
})
If you view the selectedItem
in the console, you will see that kendo adds a uid
property.
So we are findind that uid
and adding the k-state-selected
class.