我不确定如何提取第 3 和第 4 个单元格 (TD) 中的值来比较它们。如果它们具有相同的值,我想在行中添加一个 cssClass;也不知道该怎么做:
$("#grid tr").each(function() {
var theValueInCell3 = ? // how to get the cell's value?
var theValueInCell4 = ? // how to get the cell's value
if (theValueInCell3 == theValueInCell4)
{
//pseudo-code to add a cssClass to the row
$(this).addClass('foo');
}
});
编辑:这是我尝试遵循@Pechka 建议的最新尝试:
.
.
.
if (grid != null) {
grid.dataSource.data(parsedData);
setTimeout(StyleRows, 500);
}
function StyleRows() {
var grid = $('#grid').data('kendoGrid');
$("#grid tr").each(function () {
var dataItem = grid.dataItem(this); // dataItem is undefined
if (dataItem.PropA == dataItem.PropB) {
$(this).addClass('foo');
}
});
}
错误是dataItem
未定义的。