条件不起作用的Kendo UI MVC客户端模板

时间:2015-09-21 12:03:25

标签: asp.net kendo-ui

 columns.Bound(p => p.isCurrentlyLocked)
      .ClientTemplate("# if (isCurrentlyLocked && roles != 'Admin') { #"
      + "<input type='button' onclick='user_unlock' value='Unlock' class='k-button' />"
      + "# } else if(!isCurrentlyLocked && roles != 'Admin') {#"
      + "<input type='button' onclick='user_lock' value='Lock' class='k-button' />"
      + "#}#");
   columns.Template(p => p.roles).ClientTemplate("# if (roles != 'Admin') { #"
      + "<input type='button' onclick='user_delete' value='Delete' class='k-button' />"
      + "# }#");

我无法调用我的Javascript函数user_unlockuser_lockuser_delete。服务器生成类似onclick=\u0027user_delete\u0027的Html。有谁知道如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

你能尝试如下: -

columns.Template(p => p.roles).ClientTemplate("# if (roles != \"Admin\") { #"
      + "<input type=\"button\" onclick=\"user_delete()\" value=\"Delete\" class=\"k-button\" />"
      + "# }#");