2016-07-29 16 views
0

私は以下のrowTemplateを使用しています。 Valid == trueの場合、CSSクラス "ui-grid-invalid-upload-row"を適用したいと思います。どういうわけか、それは動作していません。UIグリッドRowTemplateの色はセルの値に基づいて

<div ng-repeat="(colRenderIndex, col) in colContainer.renderedColumns track by col.colDef.name" class="ui-grid-cell" ng-class="{ \'ui-grid-row-header-cell\': col.isRowHeader, \'ui-grid-invalid-upload-row\': col.colDef["Value"]==true }" ui-grid-cell></div> 
+0

あなたはあなたのコードの多くを共有してくださいすることができ – doge1ord

+0

を使用しているrowTemplateを投稿するのを忘れて、誰かがそれから助けを得る望ん。フィールドを見るのに役立つので –

答えて

0

私は上で動作しますが、私はrow.entity。[FieldName]に基づいて色を変更するために以下に使用しました。ここに投稿

function rowTemplate() { 
     return $timeout(function() { 
      return '<div ng-class="{ \'ui-grid-invalid-upload-row\': grid.appScope.rowFormatter(row) }">' + 
         ' <div ng-repeat="(colRenderIndex, col) in colContainer.renderedColumns track by col.colDef.name" class="ui-grid-cell" ng-class="{ \'ui-grid-row-header-cell\': col.isRowHeader }" ui-grid-cell></div>' + 
        '</div>'; 
     }); 
    } 

$scope.rowFormatter = function (row) { 
    return row.entity.Value === 'true'; 
}; 
0

使用row.entity.yourfieldnameしたい場合にのみセル使用にクラスを適用する場合は、カラー

作業plunker

ng-class="{\'green\':true, \'blue\':row.entity.count==1 }"などが here


ですcellClass代わり

$scope.gridOptions = { 
    enableSorting: true, 
    data:'myData', 
    columnDefs: [ 
     { field: 'sv_name', displayName: 'Nombre'}, 
     {field: 'sv_code', displayName: 'Placa'}, 
     { field: 'count', displayName: 'Cuenta', 
     cellClass: function(grid, row, col, rowRenderIndex, colRenderIndex) { 
      if (grid.getCellValue(row,col) == 1) { 
      return 'blue'; 
      } 
      return 'green'; 
     } 
     } 
    ] 
    }; 

作業plunckerは、それはあなたを助けている場合、私に教えてくださいhere

です。

0

col.colDef["Value"]==truecol.colDef[\'Value\']に変更されました。あなたは、セルの値に基づいて色を変更するようだったので、二重引用符が早まっ

<div ng-repeat="(colRenderIndex, col) in colContainer.renderedColumns track by col.colDef.name" class="ui-grid-cell" ng-class="{ \'ui-grid-row-header-cell\': col.isRowHeader, \'ui-grid-invalid-upload-row\': col.colDef[\'Value\'] }" ui-grid-cell></div> 

EDIT ng-class文は、私があなたの代わりにcellTemplateを変更すべきだと思う終了します。

関連する問題