Reputation: 1662
I need to show/hide remove(delete( icon)based on condition.for ex var a=2,var b=2;if(a=b) need to show the icon.But a!=b means hide the delete icon.How to do this?
{
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>
Upvotes: 2
Views: 655
Reputation: 7015
You can use javascript in your templates:
<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>
Check Kendo UI Templates Overview
for more detailed examples and different Template Syntax of kendo:
Render literal values: #= #
Render HTML-encoded values: #: #
Execute arbitrary JavaScript code: # if(...){# ... #}#
Upvotes: 2