I have a custom s:GridItemRenderer
that contains a single s:CheckBox
and is used to display a boolean property of the items in the grid's dataProvider
which is dependend on which dataField was set for the column:
<s:GridItemRenderer>
<s:CheckBox selected="{this.data[this.column.dataField]}"/>
</s:GridItemRenderer>
I can't (or rather: I don't want to) hardcode the property since I want to keep the renderer as generic as possible and hardcoding the property name would require me to write at least 2 otherwise identical renderers.
Now the problem is that the dataProvider contains only anonymous objects (e.g. {foo:"blah", bar:"blubb", isBaz:true}
) and databinding doesn't work with hash lookups. Since the property name is not fixed but also dynamic, I cannot use the dot syntax to access the property on the objects.
I've already searched the web for a possible solution, but didn't find any that worked. I tried using an mx:ObjectProxy
as a wrapper for the data item as suggest here but that didn't work. I tried manually creating the binding with mx:BindingUtils.bindProperty()
as suggested here but that didn't work either.
Is there any way to achieve databinding in that situation?
During some refactoring the structure of the dataProvider
changed and I was required to write specific itemRenderers
for each datagrid, so the generic approach is no longer supported and the issue basically resolved itself. :)