This question is locked. New answers and comments are not allowed.
Hello,
i'm using checkboxes for displaying bool values inside my grid. on initial load the checkboxes are always checked. in edit mode the correct values are shown. is there solution for this problem?
i'm using checkboxes for displaying bool values inside my grid. on initial load the checkboxes are always checked. in edit mode the correct values are shown. is there solution for this problem?
function
onRowDataBound(e) {
var
dataItem = e.dataItem;
setCbx($(e.row).find(
'#CanRead'
), dataItem.CanRead);
setCbx($(e.row).find(
'#CanEdit'
), dataItem.CanEdit);
setCbx($(e.row).find(
'#CanDelete'
), dataItem.CanDelete);
// always false
setCbx($(e.row).find(
'#CanCreate'
), dataItem.CanCreate);
}
function
setCbx(cbx, val) {
cbx.val(val);
if
(val) {
cbx.attr(
'checked'
,
true
);
}
}
<% Html.Telerik().Grid<
MyModel
>()
.Name( "dataGrid" )
.DataKeys( keys => keys.Add( k => k.Id ) )
.DataBinding( d => d.Ajax()
.Select("_Select", "Physician")
.Update( "_Save", "Physician" ) )
.Columns( c =>
{
c.Bound( p => p.FullName ).Width( 80 ).Title( "Name" ).Width( 300 ).ReadOnly( true );
c.Bound( p => p.CanRead ).Title( "Lesen" ).ClientTemplate( "<
input
type
=
'checkbox'
disabled
=
'disabled'
name
=
'CanRead'
checked='<#= CanRead #>' value='<#= CanRead #>' />" );
c.Bound( p => p.CanEdit ).Title( "Bearbeiten" ).ClientTemplate( "<
input
type
=
'checkbox'
disabled
=
'disabled'
name
=
'CanEdit'
checked='<#= CanEdit #>' value='<#= CanEdit #>' />" );
c.Bound( p => p.CanCreate ).Title( "Erstellen" ).ClientTemplate( "<
input
type
=
'checkbox'
disabled
=
'disabled'
name
=
'CanCreate'
checked='<#= CanCreate #>' value='<#= CanCreate #>' />" );
c.Bound( p => p.CanDelete ).Title( "Löschen" ).ClientTemplate( "<
input
type
=
'checkbox'
disabled
=
'disabled'
name
=
'CanDelete'
checked='<#= CanDelete #>' value='<#= CanDelete #>' />" );
c.Command( commands =>
{
commands.Edit();
}
);
} )
.ClientEvents( events => events.OnRowDataBound( "onRowDataBound" ) )
.Render(); %>