Display boolean field as checkbox

Thread is closed for posting
10 posts, 1 answers
  1. Jaap
    Jaap avatar
    96 posts
    Member since:
    Oct 2012

    Posted 16 Jan 2012 Link to this post

    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. Answer
    Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 17 Jan 2012 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
  4. Jaap
    Jaap avatar
    96 posts
    Member since:
    Oct 2012

    Posted 17 Jan 2012 Link to this post

    Ok, thank you, that did the trick.

    Jaap
  5. Andrew
    Andrew avatar
    9 posts
    Member since:
    Jan 2012

    Posted 02 Feb 2012 Link to this post

    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.
  6. Jaap
    Jaap avatar
    96 posts
    Member since:
    Oct 2012

    Posted 03 Feb 2012 Link to this post

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

    Jaap
  7. Juan Carlos
    Juan Carlos avatar
    1 posts
    Member since:
    Jun 2012

    Posted 14 Feb 2013 Link to this post

    How i can implement this in Razr?

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

    Thanks.
  8. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 15 Feb 2013 Link to this post

    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!
  9. Mike
    Mike avatar
    1 posts
    Member since:
    Feb 2013

    Posted 19 Feb 2013 Link to this post

    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
  10. Leo
    Leo avatar
    3 posts
    Member since:
    Jan 2013

    Posted 19 Feb 2013 Link to this post

    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
  11. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 20 Feb 2013 Link to this post

    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!
Back to Top
Kendo UI is VS 2017 Ready