If that's all you're wanting to do, you could do without a transform (unless I'm misunderstanding you).
Suppose your dataset tag starts with 3 columns:
city | country | population
The first thing I would do is to add 2 more columns:
city | country | population | iconPath | state
with the iconPath
column holding your icon's path, and the state column holding either a text or a numeric state
value (in your example, you only have two states - green and red, which probably corresponding to running and error/stopped).
Then, in your Icon view, you would create some view params, namely, one called rowData
- this object gets automatically passed into your Icon view when you render a column as a view.
The rowData
object will contain this row's data. So for instance, for row 0, the rowData
object will be all of the fields in row 0, something like
{
"city": "",
"country": "",
"population": "",
"iconPath": "material/hello",
"state": "running"
}
Then, in your Icon view, you can read this rowData.state
property and use it in a binding to set your icon's color. Similarly, you can also have a dynamic icon path, using the rowData.iconPath
property.
The last few points I want to make is that the iconPath
and state
columns can be set to visible: false
and those values still appear in the rowData
. The last thing is that you can change the icon
column's header.title
property to set the column text to Status
.
This would be much easier to show - a bit harder to type out. Let me know if you have any questions about what I said or if I'm way off!