Search code examples
angularjsrowng-grid

How to set row color in ng-grid based on a cell value which is a text?


I am referring to this plunkr: http://plnkr.co/edit/X4SqsjGtlDOJQrkrYWv6?p=preview I want to set the color of a row as green if the pedido is "A001". How should I do this? I tried changing the **ng-class, but doesn't seem to work because it is "A001"

Please let me know if I have to change something else

var rowTemplate = `
    <div style="height: 100%"
         ng-class="{red: row.getProperty('\pedido\') == C003,
                    green: row.getProperty('\pedido\') == A001}">
       <div ng-style="{'cursor': row.cursor }"
            ng-repeat="col in renderedColumns"
            ng-class="col.colIndex()" class="ngCell ">
           <div class="ngVerticalBar" ng-style="{height: rowHeight}"
                ng-class="{ ngVerticalBarVisible: !$last }">
           </div>
           <div ng-cell>
           </div>
       </div>
   </div>
`;

Solution

  • It's always set class = A001 you should change = to ==

    green: row.getProperty(\'pedido\') = A001
    

    change to

    green: row.getProperty(\'pedido\') == \'A001\'