我需要显示/隐藏删除(删除(icon)基于condition.for ex var a = 2,var b = 2; if(a = b)需要显示icon.But a!= b表示隐藏删除图标。如何执行此操作?
{
command: {
template: kendo.template($("#remove").html())
}, title: " ", width: "40px"
}
<script id="remove" type="text/x-kendo-tmpl">
<a href="" onclick="remove(this); return false;">
<img src="@Url.Content("~/Images/delete_icon.gif")" alt="Remove item" />
</a>
</script>
答案 0 :(得分:2)
您可以在模板中使用javascript:
<script id="remove" type="text/x-kendo-tmpl">
# var a=2; var b=2;#
# if(a==b){ #
<a href="" onclick="remove(this); return false;">
<img src="@Url.Content("~/Images/delete_icon.gif")" alt="Remove item" />
</a>
# } #
</script>
检查Kendo UI Templates Overview
以获取更多详细示例和kendo的模板语法:
Render literal values: #= #
Render HTML-encoded values: #: #
Execute arbitrary JavaScript code: # if(...){# ... #}#