javascript 如何隐藏剑道网格命令编辑按钮或删除按钮?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28727678/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 09:26:55  来源:igfitidea点击:

How to hide kendo grid command edit button or delete button?

javascriptjquerykendo-uikendo-grid

提问by Ironman

I want to hide kendo grid command edit button or delete button based on role. + How to hide command column if needed.Thanks

我想根据角色隐藏剑道网格命令编辑按钮或删除按钮。+ 如果需要,如何隐藏命令列。谢谢

 { command: [{ name: "Details", click: showDetails },
             { name: "Edit", click: onEdit },
             { name: "Delete", click: obDelete, hidden:true}], title: 'Actions', width: 230 }

回答by Neal Gabriel

Just in case, if someone needs an answer (Reference: http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#configuration-columns.command.visible)

以防万一,如果有人需要答案(参考:http: //docs.telerik.com/kendo-ui/api/javascript/ui/grid#configuration-columns.command.visible

<div id="grid"></div>
<script>
$("#grid").kendoGrid({
  columns: [
    { field: "name" },
    { command: [{ name: "edit", visible: function(dataItem) { return 
dataItem.name==="Jane" } }] }
  ],
  editable: "popup",
  dataSource: [ { name: "Jane" }, { name: "Bill" } ]
});
</script>