Instead use the dataTransform
function to add an attribute to the JSON used to construct the view, and then with the added custom attribute, call it much like any other attribute. For example:
<View dataCollection="videos" dataFilter="recentlyAddedFilter"
dataTransform="recentlyAddedTransform">
<!-- Pass the customWidth attribute that was added in the transform function -->
<ImageView image="{img}" width="{customWidth}">
<Label text="{title}"></Label>
</ImageView>
</View>
So your controller would look like this:
// Takes a collection
function recentlyAddedFilter(collection) {
return collection.where({title:'A title'});
}
// Takes a model
function recentlyAddedTransform(model) {
// Make sure to convert the model to JSON
var transform = model.toJSON();
// Add a custom width attribute to the model
transform.customWidth = "200dp";
return transform;
}
Remember that in the dataTransform
function you are working with an individual model, but you are returning JSON.