How to set DataView type conditionally based on data field


I want to set the background-color of the items in a DataView based on a priority field in the data - the background-color for each item would be based on its priority. How would you suggest I do this?

This seems to be defined in the type, and if so please tell me the best way to condition the “type” of my DataView based on a field in the incoming record. I can see how to use a function to conditionally select the template data, but I want to set the css of the item.

In grids I use the “forEachRow” method to iterate thru the items to set attributes. Is there something similar for DataView that I could use if there is not a better way to do it while loading?



You may try to define the templates for your dataview items.
Here you can find a tutorial: