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

[Solved] Clienttemplate conditional dormatin (Image)

1 Answer 88 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
orim
Top achievements
Rank 1
orim asked on 26 Jul 2012, 11:41 AM
Hi,
i have a clienttemplate for my column like this
.ClientTemplate("<img width='16' height='16' alt='<#= Status #>' title='<#= Status #>' src='" + Url.Content("~/Content/Images/Status/") + "<#= Status #>.png' />")

so what i need is somthing like this. The status arrives from Database when the value is NULL

if status=nothing then
.ClientTemplate("<img width='16' height='16' alt='<#= Status #>' title='<#= Status #>' src='" + Url.Content("~/Content/Images/Status/nothing.png' />")
else
.ClientTemplate("<img width='16' height='16' alt='<#= Status #>' title='<#= Status #>' src='" + Url.Content("~/Content/Images/Status/") + "<#= Status #>.png' />")
end if

Thanks for any help

1 Answer, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 27 Jul 2012, 11:58 AM
Hi Miroslav,

 You can call a JavaScript function in your template which can determine the right image:

.ClientTemplate("#= imageUrl(Status) #");


<script>

function imageUrl(status) {
     if (status == null) {
         return "<img src="empty" />";
     } else {
         return "<img src="not-empty" />"; 
     }
}

</script>
Regards,
Atanas Korchev
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
Tags
Grid
Asked by
orim
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or