This is a migrated thread and some comments may be shown as answers.

the checkbox text in grid

4 Answers 256 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 26 Feb 2013, 10:41 AM
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

4 Answers, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 27 Feb 2013, 04:21 PM
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!
0
Daniel
Top achievements
Rank 1
answered on 28 Feb 2013, 10:17 AM
when using ClientTemplate or Template on a grid column,i can put any html code?
0
Accepted
Vladimir Iliev
Telerik team
answered on 28 Feb 2013, 01:51 PM
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!
0
Daniel
Top achievements
Rank 1
answered on 01 Mar 2013, 11:13 AM
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
Tags
Grid
Asked by
Daniel
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Daniel
Top achievements
Rank 1
Share this question
or