Hi, im trying to use cellClassRules in my dash ag grid to highlight the cell yellow if an invalid input is entered. For one of my columns i require the user to input a list of numbers.
I am trying to check if any of the numbers are less than 0 in the list. So the user will enter in the grid for example 1,5,-4,10 which is stored in the grid data as a string of ‘1,5,-4,10’. I need to convert this into a list like [1,5,-4,10] and check if any of the numbers in the list are less than 0. I am having trouble coding this as a conditional statement in my celllClassRules section of my column defs. Here is my code for that specifc columnDef.
{‘headerName’: ‘Distance between Sources and SBC’,
‘field’: ‘Distance between Sources and SBC’,
‘cellDataType’: ‘text’,
‘headerTooltip’ : ‘Distance (m)’,
‘cellClassRules’: {
‘invalid-input’: “params.value !== null && params.value.split(‘,’).map(Number).some((x) => x < 0)”}}
The cellClassRules section of the code doesnt seem to work though. Any guidance would be greatly appreciated.
Thanks