如何在模板中隐藏基于另一个字段'值的元素- kendoui网格

how to hide the element in template based on another field's value - kendoui grid

本文关键字:元素 网格 kendoui 字段 另一个 隐藏      更新时间:2023-09-26

我有一个列如下。

var commentsTemplate = "<input class='comments-button' type='image' src='images/comments_button.png'/>#: COMMENTS #";
{ "field": "COMMENTS", "title": "Comments", "template": matcher_comments_template},
{ "field": "TYPE", "title": "Type"},

我希望输入元素根据TYPE字段的值动态显示和隐藏。例如,如果type是Good,隐藏按钮,如果type不是Good,显示按钮。什么好主意吗?

谢谢

using ng-show:

var commentsTemplate = "<input class='comments-button' type='image' src='images/comments_button.png' ng-show="{{currentValue.title == "Good"}}"/>#: COMMENTS #";

假设currentValue是一个父对象,你的主要javascript对象({ "field": "TYPE", "title": "Type"},)存储。

编辑1

OP要求实现不绑定他的变量。我怎么能认为这是一个"自制手表"在控制器:

<input class='comments-button' type='image' src='images/comments_button.png' ng-show="shouldShowMe()"/>

,在控制器中:

$scope.shouldShowMe = function(){
  return title == "Good";
}