Reputation: 141
columns.Bound(p => p.Active).ClientTemplate("\\#if('#=Active#'=='Y') {\\<input type='button' value='OK' />\\}\\#").Width(150).Title("Status");
but condition is taken as string??
#if('Y'=='Y')`enter code here` {
<input type="button" value="OK">
}#
Upvotes: 14
Views: 43524
Reputation: 2331
This worked for me but note do not use href='#' it will break the template compiler.
c.Bound(p => p.ItemNumber)
.Width(64)
.ClientTemplate("# if (ItemCommentActive) { #" +
"<a href='void(0);' title='#=Comments#' onclick='return false;'>#=ItemNumber#</a>" +
"# } else { #" +
"<div>#=ItemNumber#</div>" +
"# } #");
Upvotes: 0
Reputation: 1
columns.Bound(searchModel => searchModel.Value).ClientTemplate(
"#if(Name=='DevboardTask'){# " +
"<a href='\\#UpdateStatusWindow' onclick=\"javascript:openflexpmtask('#=Value#');\">#=Value#</a> " +
"#} else {# " +
"<a\">#=Value#</a> " +
"#}#");
This might help you. This is just an example...
Upvotes: -1
Reputation: 163
I hope you get the solution....
columns.Bound(p => p.IsActive)
.ClientTemplate(
"\\# if (IsActive != false) { \\#" +
"\\<input type=\"checkbox\" id=\"checkBox\" class=\"parentCheckBox\" window-call=\"template\" checked/>\\" +
"\\# } else { \\#" +
"\\<input type=\"checkbox\" id=\"checkBox\" class=\"parentCheckBox\" window-call=\"template\" />\\" +
"#\\ } \\#")
.Width(10);
Upvotes: 7
Reputation: 4178
There are three ways to use the hash syntax in a Kendo template:
#= #
#: #
# if(...){# ... #}#
So in your code you would have to write
columns.Bound(p => p.Active).ClientTemplate(
"#if(Active=='Y') {#
<input type="button" value="OK">
#}#").Width(150).Title("Status");
Notice in the sample how the #
signs separate inside code from outside code. When you're inside code you don't have to use #
again to access a variable and that's why Active can be without #
before.
Upvotes: 34
Reputation: 5083
To have data values rendered in your Kendo template you could use the following as a guide:
columns.Template(@<text></text>)
.ClientTemplate("#if (Field3 == true) {#"
+ "<a onclick='jsFoo(#=Id#)' href='\\#'></a> "
+ "#} #").Width(70).Title("ColA");
Upvotes: 5
Reputation: 8020
Try this,
columns.Bound(p => p.Active).ClientTemplate(
"# if (IsServiceExist) { #" +
"<input type='button' value='OK' />"+
"# }#").Width(150).Title("Status");
Upvotes: 8