the checkbox text in grid

5 posts, 1 answers
  1. Daniel
    Daniel avatar
    192 posts
    Member since:
    Mar 2012

    Posted 26 Feb 2013 Link to this post

    Hello again,
    i noticed that for a bit(boolean) type i have the text true/false in the grid column.Is it possible to have the same checkbox like in edit mode?and if true then to be checked,if false  not,also to change the text from true/false for example to  yes/no ?

    Regards,
    Daniel
  2. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2194 posts

    Posted 27 Feb 2013 Link to this post

    Hi Daniel,

     
    Basically showing the same checkbox as in edit mode which is bound to the underling model will require custom code - please check the example below:

    Define client template:

    columns.Bound(p => p.Discontinued).ClientTemplate("<input type='checkbox' onclick='editCurrentCell(this)'  name='Discontinued' #= Discontinued? checked='checked' : '' # />");

    editCurrentCell function:
    function editCurrentCell(element) {
        $("#Grid").data("kendoGrid").one("edit", function (e) {
            if (e.model.Discontinued) {
                e.model.set("Discontinued", false);
            }
            else {
                e.model.set("Discontinued", true);
            }
            //For testing purpose only
            console.log(e.model.Discontinued);
        });
        $("#Grid").data("kendoGrid").editCell($(element).closest("td"));
    }

    Also you can change the default texts for boolean type using ClientTemplate:
    columns.Bound(p => p.Discontinued).ClientTemplate("#=Discontinued ? 'yes': 'no'#");
    Kind Regards,
    Vladimir Iliev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Daniel
    Daniel avatar
    192 posts
    Member since:
    Mar 2012

    Posted 28 Feb 2013 Link to this post

    when using ClientTemplate or Template on a grid column,i can put any html code?
  4. Answer
    Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2194 posts

    Posted 28 Feb 2013 Link to this post

    Hi Daniel,

     
    You can use HTML code inside templates - for more information about the client template syntax I would suggest to check this article.

    Kind Regards,
    Vladimir Iliev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  5. Daniel
    Daniel avatar
    192 posts
    Member since:
    Mar 2012

    Posted 01 Mar 2013 Link to this post

    it is ok now,i put also the attribute disabled=true in the template,because otherwise the checkbox can be edited without pressing the button edit,and i didn't want that.
    Thanks for all the information.

    Best Regards
Back to Top