I have two checkboxes in a Kendo MVC Grid row and need some understanding as to how to set the dataitem property when they are clicked. I have been successful when there is one checkbox per row doing the following:
columns.Bound(p => p.bDelete).ClientTemplate("<
input
type
=
'checkbox'
name
=
'bDelete'
Id
=
'bDelete'
#= bDelete ?
checked
=
'checked'
: '' #
class
=
'chkbx'
/>")
.Width(70).HtmlAttributes(new { style = "text-align: center", title = "Delete Selected" });
<script>
// Any rows that get checked or unchecked after the form is loaded need
// to pass though this event to get the underlying record reconciled
$(
function
() {
$(
'#Grid'
)
.on(
'click'
,
'.chkbx'
,
function
(e) {
debugger;
var
checked = $(
this
).is(
':checked'
);
var
grid = $(
'#Grid'
).data().kendoGrid;
var
dataItem = grid.dataItem($(
this
).closest(
'tr'
));
// if we are in insert mode do not let the user check the delete checkbox
if
(dataItem.iProjectSequence == 0) {
e.preventDefault();
dataItem.set(
'bDelete'
,
false
);
return
;
}
dataItem.set(
'bDelete'
, checked);
dataItem.set(
'bModified'
,
true
);
dataItem.set(
'dirty'
,
true
);
SetRowsModifiedState();
SetPageMessage(
"Data Modified"
);
$(
"#New"
).prop(
"disabled"
,
true
);
$(
"#Cancel"
).prop(
"disabled"
,
false
);
});
})
</script>
The code above works for a row that has only one checkbox in it. How do I detect the underlying model value attached to the checkbox being clicked so that I can set *ONLY* that field?
Thanks