Display boolean field as checkbox

2 Answers 7733 Views
Grid
This question is locked. New answers and comments are not allowed.
Jaap
Top achievements
Rank 2
Jaap asked on 16 Jan 2012, 03:12 PM
By default the value of a boolean field is displayed as the text "true" or "false". But I want a checkbox to be displayed.
So I want to add a template on the column:
<input type="checkbox" checked="checked" disabled="disabled" /> 

My problems is how add the checked="checked" conditionally depending on the value of the field.
Any idea how to do that?

Thanks, Jaap

2 Answers, 1 is accepted

Sort by
0
Accepted
Rosen
Telerik team
answered on 17 Jan 2012, 09:57 AM
Hello Jaap,

In order to set the checked attribute based on the value of the field, you should use similar to the following template declaration:

{
 field: "Discontinued",
 template: '<input type="checkbox" #= Discontinued ? "checked=checked" : "" # disabled="disabled" ></input>'
}


Regards,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Jaap
Top achievements
Rank 2
commented on 17 Jan 2012, 11:27 AM

Ok, thank you, that did the trick.

Jaap
Andrew
Top achievements
Rank 1
commented on 03 Feb 2012, 05:44 AM

The .... "checked=checked" .... bit should be .... checked="checked" ....

I'm only adding this because it took me 10mins to realise the first quote was in the wrong place.
Jaap
Top achievements
Rank 2
commented on 03 Feb 2012, 08:25 AM

I looked in my code and saw indeed that the quote was also in the wrong place. But still it worked.

Jaap
Juan Carlos
Top achievements
Rank 1
commented on 14 Feb 2013, 08:10 PM

How i can implement this in Razr?

{
columns.Bound(p => p.Active)
.Template(???????);
}

Thanks.
Rosen
Telerik team
commented on 15 Feb 2013, 09:14 AM

Hi Juan,

Please refer to this help article.

Regards,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Mike
Top achievements
Rank 1
commented on 19 Feb 2013, 04:26 PM

Rosen,

I don't see the Razor syntax in the help article that you suggested.  And when I use the .ClientTemplate that you suggested, it doesn't seem to bind back to the model property.

Thanks,
Mike
Leo
Top achievements
Rank 1
commented on 20 Feb 2013, 05:49 AM

Basically Is there any one who has done the two way binding on the grid for a checkbox. I want to develop a editable checkbox. but when i click it returns a textbox. not a checkbox. need a help
0
Rosen
Telerik team
answered on 20 Feb 2013, 07:25 AM
Hello Leonard,

To customize the appearance of the column during editing you should specify a column editor. Here is a demo of this functionality.

As the discussion diverged from the initial topic of the thread please consider starting a new one if further question arise.

Regards,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Jaap
Top achievements
Rank 2
Answers by
Rosen
Telerik team
Share this question
or