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

How to bind boolean to image icon in column

1 Answer 583 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nattapong
Top achievements
Rank 1
Nattapong asked on 26 Jun 2013, 05:51 AM
Hi, How to bind grid with property is boolean  but  i want to bind is image .

I follow  http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/helpers/grid/faq  and do it 

but i result is not to me need.
columns.Template(p => p.IsPublished).ClientTemplate(
          "# if(IsPublished.GetValueOrDefault(false)) { #" +
          "<img src='"+ Url.Content("~/Images/icon_true.gif") +"' alt='#= IsPublished #' />"+
          "# } else { #" +
          "<img src='"+ Url.Content("~/Images/false-icon.png") +"' alt='#= IsPublished #' />"+
          "# } #"
          );

1 Answer, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 27 Jun 2013, 09:13 AM
Hello Nattapong,


The syntax of the template is correct. The reason for the issue is the call to the GetValueOrDefault method in the if statement. Please keep in mind, that the templates are rendered on the client side, so you cannot use C# function calls inside.

I hope that this information was helpful for you. I wish you a great day!

 

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