Reputation:
i have a status column in my model which is true or false. i show this column on telerik grid for mvc when item is true checkbox is checked and while false is unchecked.
Problem is i want bind custom event to checkbox to toggle item status. How can bind custom event to checkbox and on check or uncheck update item.
I show in grid view :
columns.Bound(o => o.Status).ClientTemplate("<input type='checkbox'
name='Status' value='<#= Status#>' />");
Upvotes: 2
Views: 3002
Reputation: 30671
You can either use jQuery:
$("#Grid").delegate("[name=Status]", "click", function() {
var checkBox = this;
alert(checkBox.checked);
});
or add an onclick attribute to the checkbox:
columns.Bound(o => o.Status).ClientTemplate("<input type='checkbox' name='Status' value='<#= Status#>' onclick='checkboxClicked(this)' />");
function checkboxClicked(checkBox) {
alert(checkBox.clicked);
}
Upvotes: 2