I am running python 3.12.4 dash 2.17.1 dash_ag_grid 31.2.0 on linux OpenSUSE Tumbleweed
I am using Dash AG Grid to build a table.
I am trying to format certain rows based on the value of the first field in the row. I am referencing params.data.fieldName as shown below, but the fieldName contains a space. How can I access the contents of params.data.fieldName if fieldName contains a space and is actually ‘Strategy Name’ (not ‘StrategyName’)?
getRowStyle = {
“styleConditions”: [
{“condition”: “params.data.StrategyName == ‘Util’”, “style”: {“backgroundColor”: “grey”},},
],
},
I have searched extensively but not found any answer. Any help is much appreciated.
Hi @gatomulato and welcome to the Dash community 
Good question! You can find lots of good tips in the Troubleshooting section, such as the topic of Dot Notation Not Working
You can use brackets - just like in Pandas. So instead of params.data.StrategyName
you can use params.data["Strategy Name"]
Thank you for your answer.
Firstly, I apologise because I did not find the section Dot Notation Not Working. I try to not ask questions that I can answer myself, so I guess my seach-fu needs improvement.
I did try python brackets before posting. I used single quotes because the condition is already wrapped in double quote. It failed to work, but I realise now I did not remove the dot from the syntax. The following works great.
getRowStyle = {
“styleConditions”: [
{“condition”: “params.data[‘Strategy Name’] == ‘Util’”, “style”: {“backgroundColor”: “grey”},},
],
},
Thanks again.
1 Like