2014-02-25 50 views
2

我需要显示/隐藏删除(删除(图标)基于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> 

回答

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更详细的例子,不同的剑道的模板语法

  1. Render literal values: #= #
  2. Render HTML-encoded values: #: #
  3. Execute arbitrary JavaScript code: # if(...){# ... #}#