[英]Gray out a row in kendo grid based on column value
I have a Kendo Grid whose values get populated based on a post call. 我有一个Kendo Grid,它的值根据帖子调用填充。 I need to gray out an entire row if one of the column has a value "REGISTERED".
如果某列中的一个值为“ registered”,则需要将整行显示为灰色。
Is there a way we can achieve this? 有没有办法可以做到这一点?
Add a handler function for the onDataBound event . 为onDataBound事件添加一个处理函数。 In the onDataBound event handler, add jQuery that grey out column, something like this:
在onDataBound事件处理程序中,添加灰色列的jQuery,如下所示:
function onDataBound(event) {
// ...
// Assumes your Kendo grid DOM element, or other appropriate element enclosing your disabled rows, is in the "el" variable
el.find( ":contains('REGISTERED')" ).addClass("disabled");
}
<style>
.disabled { color: #999; } /* Or however you want to grey it out */
</style>
Look this example, I'm checking every row to see if it matches a condition, then colouring it. 看这个例子,我正在检查每一行,看是否符合条件,然后给它上色。 You just need to add this event in the DataBound event of the grid like this
您只需要像这样在网格的DataBound事件中添加此事件
.DataBound("onRowBound")
Then, check the condition 然后,检查条件
static onRowBound(e) {
var grid = $("#Funciones").data("kendoGrid");
grid.tbody.find('>tr').each(
function () {
var dataItem = grid.dataItem(this);
if (dataItem.ColumnName == "REGISTERED") {
$(this).css('background', 'gray');
}
});
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.