Trouble applying cell class rules to Ag-Grid in Angular using typescript .

I have created cell class rules as follows :

'style-class-1': function(params) { return params.value === 1}
'style-class-0': function(params) { return params.value === 0}

style-class-1 is applied when params.value is 1

style-class-0 is not applied when params value is 0

1 Answers

A Ghanima On Best Solutions

The only reason this would not work is because params.value might be a string (or anything other than an int) while you're strictly comparing it to an integer. To get around this, you can do one of the following.

Compare it with a string

params.value === '0'

Or parse params.value as Integer

parseInt(params.value) === 0

Or use == instead of === which will result in javascript converting the values to the same type

 params.value == 0