Kendo UI:网格:基于每行第3和第4单元格中值的比较的条件样式

Tim*_*Tim 2 each jquery html-table css-selectors kendo-ui

我不知道如何在第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');
             }

    });
Run Code Online (Sandbox Code Playgroud)

编辑:这是我最近的尝试,试图遵循@ 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');
        }

    });
   }
Run Code Online (Sandbox Code Playgroud)

错误dataItem是未定义的.

Pet*_*bev 5

您好我建议您使用dataItem方法,该方法用于检索与该行相关的基础模型.例如

var grid = $('#grid').data().kendoGrid;
$('#grid tr').each(function(){
     var dataItem = grid.dataItem(this);
     if(dataItem.PropName == dataItem.SomeOtherProp){
          $(this).addClass('foo');
     }
})
Run Code Online (Sandbox Code Playgroud)