1

How do I modify this example to highlight green for > 30, red for < 20 and orange for remainder?

$scope.gridOptions = { 
    data: 'myData',
    rowTemplate: '<div style="height: 100%" ng-class="
                                        {green: row.getProperty(\'age\')  < 30}">
                      <div ng-repeat="col in visibleColumns()"
                           class="ngCell col{{$index}} {{col.cellClass}}"ng-cell>
                      </div>
                  </div>'
};

color-grid

Official plnkr for the code (and to run it)

1 Answer 1

2

use orange as default class, and apply the other classes conditionally, but in Css, the green and red should be declared after orange, so it will overwrite orange. this should do it:

<div style="height: 100%" 
      ng-class="{ green: row.getProperty(age)>30, 
                  red: row.getProperty(age) < 20}" 
      class="orange">
</div>

or use this without minding css ordering:

 <div style="height: 100%" 
      ng-class="{ green: row.getProperty(age)>30, 
                  red: row.getProperty(age) < 20,
                  orange: 20 <= row.getProperty(age) <= 30}" >
</div>
Sign up to request clarification or add additional context in comments.

1 Comment

Ahhh, the comma notation. So simple now that I think about it. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.