I'm currently rewriting some of my code to implement a databind with ListView rather than View, but im running into an issue.
View id="education" class="vertical"> <ListView id="list" defaultItemTemplate="template" class="vertical padding_s"> <Templates> <Require src="profile/user/row" /> </Templates> <ListSection id="section" dataCollection="users" dataTransform="userTransform"> <ListItem education:text="{education}" education:color="{educationColor}" levelAndGraduated:text="{levelAndGraduated}" levelAndGraduated:color="{levelAndGraduatedColor}" school:text="{school}" school:color="{schoolColor}" period:text="{periodText}" period:color="{periodColor}" /> </ListSection> </ListView> </View>I'm using the
userTransform function which sets the attributes depending on the property availability. For instance, when school is unavailable, it sets the schoolColor property and passes it back in the object at the end of userTransform.
However, i'd like to have the transform function pass back an object like
function userTransform(model) { model = model.toJSON(); model.period = { text: 'periodtext', color: '#f00' } return model;and then be able to use it like:
<ListItem period:text="{period.text}" period:color="{period.color}" />Instead of assigning 2 properties like
model.periodText and model.periodColor.
It would make some of my logic much more clear because that way I can use a key named color instead of [property]color.
It might not seem like a huge improvement but it is a slight alteration that would make my code much more reusable.
In the BEST case it would be handy to not have to assign ANY of the x:x attributes in the XML, but instead return it from the transform function.
I'm hoping there is some undocumented object/array/syntax I can use?