Node-red-node-ui-table formatting one field based on values in another

I would like to get this field to be green when above zero, red below zero with the progress bar showing the absolute magnitude.

Currently if it is negative, it doesn't display (understandably).
can I either: refer to another field in the same row in my if statement (and pass an absolute value to this field) or can I convert the value of this field to an absolute value?
{
"title": "Result",
"field": "cpaPlusKnColour",
"formatter": "progress",
"formatterParams": {
"min": 0,
"max": 100,
"color": "function(value){return(value > 0 ? 'green' : 'red');}",
"legendColor": "#000000",
"legendAlign": "center",
"width": 70,
"align": "center"
}

Hi,

(First please use the code formatting function when you post any code or json)

Perhaps take a look into the ui_control example provided with ui-table (menu/import/examples). There is a progress bar formatter callback included that perhaps do what you try to achieve.

Thanks for replying. I'm still struggling to get this to work.
What I would like to do is colour one field based on another field.
i.e. I have a field called "colour" containing "red"
I have another field called "magnitude" containing a number.
I would ideally like to display a progress bar based on the number in the field "magnitude" coloured by the field called "colour", but if that is too tricky, then at least display the number in the colour. I am assuming that I can use functions like row.getCell(10) assuming the "colour" field is 10th in the array, but I don't really know how.

Sorry to answer so late.

You can't access data from other columns as the formatter callback only give you the value of THIS column, not the complete row.

I "think" (and I tested it once but can't remember the success) you can use a field identifier more than once [{title:"Column 1",field:"value1"],[title:"Column 2",field:"value1"] and use different formatters for each column.

Or you copy your value into to different fields before sending them to ui-table.

Thanks again for your response. In the end I resorted to raw HTML and that enabled me to format the data correctly.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.