问题
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