Make Command Button invisible in Kendo Grid

谁说我不能喝 提交于 2019-12-11 18:53:16

问题


I am new to kendo UI. In my code, columns are getting created as shown below.

grid = $('#grid').kendoGrid({
            columns: [
                {
                    width: 75,
                    command: [{
                        name: "Tag",
                        click: function (e) {
                            try {
                             } catch (ex) {
                                alert(ex.message);
                            }
                        }
                    }]
                },
               { field: "Col18", title: "IsTag", width: 75 },
               { field: "Col8", title: "System", width: 75 },
          ],

Now, in the databound, based on the value from datasource, they are changing the color of the row as show below. My issue is, if the color is green, I want to hide the command button. How can I achieve this.

 dataBound: function () {
                dataView = this.dataSource.view();
                for (var i = 0; i < dataView.length; i++) {
                    var obj = $("#grid tbody").find("tr[data-uid=" + dataView[i].uid + "]");
                    switch (dataView[i].Aklr) {
                        case "R":
                            obj.addClass("red");
                            break;
                        case "R+":
                            obj.addClass("darkred");
                            break;
                        case "G":
                            obj.addClass("green");
                             break;
                    }

                }
            }

回答1:


Since you have already added a class to your table row you can accomplish this with CSS.

http://jsbin.com/fogulena/3/edit?html,css,js,output

.green .k-grid-Tag {
  display: none;
}



回答2:


Here, I find the answer.

$("#grid tbody").find("tr[data-uid=" + dataView[i].uid + "] td:eq(0)").html("");



来源:https://stackoverflow.com/questions/24664064/make-command-button-invisible-in-kendo-grid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!