简体   繁体   中英

Condition in kendo grid ClientTemplate

I am using kendo grid in asp.net mvc4. A column of a grid is Email, so I make a link to the column like that:

col.Bound(con => con.EmailName).Title("Email").Width(120).ClientTemplate("<a href=\"mailto:#=EmailName#\"> #=EmailName == null ? '': EmailName#</a>").Filterable(true);

It's Working well. But, I also have to field DoNotEmail and DoNotEmailMarketingCampaigns Whose are Boolean. I want to make the link if both field are false, otherwise I will not make a link. I tried following way:

col.Bound(con => con.EmailName).Title("Email").Width(120).ClientTemplate("#if(!DoNotEmailMarketingCampaigns && !DoNotEmail) { # <a href=\"mailto:#=EmailName#\"> #=EmailName == null ? '': EmailName#</a> #} else { #=EmailName == null ? '': EmailName# } #").Filterable(true);   

but it's not serving my purpose. Any suggestions?

最后完成以下代码:

col.Bound(con => con.EmailName).Title("Email").Width(120).ClientTemplate("#if(!DoNotEmailMarketingCampaigns && !DoNotEmail) { # <a href=\"mailto:#=EmailName#\"> #=EmailName == null ? '': EmailName#</a> #} else {# #=EmailName == null ? '': EmailName# #} #").Filterable(true);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM