mercredi 7 janvier 2009

Flex DataGrid cannot handle complex XML

I have an XML like:

...and it seems that you cannot bind the node PhoneNumbers/PhoneNumber in the datagrid using something like:
< mx:datagridcolumn datafield="PhoneNumbers.PhoneNumber.@id"
So, to archieve it, you can use the "labelFunction" to get access to the nested structure...but I prefer to re-build a flat XML from the original one!
So, the solution I found: I use a getter/setter for my bindable XMLListCollection property, and in the setter, I create the "flat copy"
Not clear?

Here is the code:



Last minute: a *VERY* interesting article that explains how to deal with nested XML structures: link.