Hello, I'm having trouble setting up checkbox column in my grid. I am using inline edit mode and my checkbox column is se up like this
and script handling check events is
The problem I'm experiencing is very weird. Binding to bool field from database works fine, editing also but when inserting, checkbox always passes as false. Very weird. Also, I would like the checkbox to be disabled if the row is in read only mode and to be editable if the row is in edit/insert mode. Any help? Lost few hours on this and this is too much :)
@(Html.Kendo().Grid<
URBIS.ViewModels.PropisiViewModel
>()
.Name("grid")
.Events(e => e.DataBound("onDataBound"))
.Columns(columns =>
{
columns.Bound(p => p.GrupePropisa).ClientTemplate("#=GrupePropisa.Naziv#").EditorTemplateName("GrupePropisa").Width(220);
columns.Bound(p => p.Naziv).Width(220);
columns.Bound(p => p.SluzbeniList).Width(220);
//columns.Bound(p => p.Aktivan).Width(120);
columns.Bound(p => p.Aktivan)
.Title("Aktivan")
.ClientTemplate("<
input
type
=
'checkbox'
#= Aktivan ?
checked
=
'checked'
: '' #
class
=
'chkbx'
/>")
.HtmlAttributes(new {style = "text-align: center"})
.Width(50);
})
and script handling check events is
$(function () {
$('#grid').on('click', '.chkbx', function () {
var checked = $(this).is(':checked');
var grid = $('#grid').data().kendoGrid;
var dataItem = grid.dataItem($(this).closest('tr'));
dataItem.set('Aktivan', checked);
});
});
The problem I'm experiencing is very weird. Binding to bool field from database works fine, editing also but when inserting, checkbox always passes as false. Very weird. Also, I would like the checkbox to be disabled if the row is in read only mode and to be editable if the row is in edit/insert mode. Any help? Lost few hours on this and this is too much :)