PDA

View Full Version : Binding XML attributes to DataGrid


laureen
11-14-2006, 01:01 PM
Hello to all,

i am trying to bind the following dynamic XML data structure to a DataGrid:
<data>
<object id="21" type="phone" state="0" name="Charly">
<object id="22" type="phone" state="1" name="Bob">
<object id="23" type="phone" state="9" name="Wendy">
</data>

this data structure is given by another software and is updated using XML Sockets. Lets say we call this "appdata". The "state" changes (by remote update) and shall also change inside the DataGrid.

The thing i got working:

<mx:XMLListCollection id="agentdata" source="{appdata.object.(@type == 'phone')}" />
<mx:DataGrid id="agents" dataProvider="{agentdata}">
<mx:columns>
<mx:DataGridColumn headerText="Phones" dataField="@name" />
</mx:columns>
</mx:DataGrid>


Now the problem:

Now i would like to create a dynamic DataGrid in Flex2 that shows the
contents of field "name". The cell showing the name should have a background color that depends on the field "state". Does anyone have an idea or can give a hint on how to handle this?

Thanks,
Laureen

CDHBookingEdge
11-14-2006, 08:36 PM
Hey Laureen, this may or may not be an answer but if you look at the very recent post dynamic display of data (http://www.actionscript.org/forums/showthread.php3?t=119786) it sounds very similar to the thing(s) you're trying to accomplish. It seems to me that you're both trying to display/redisplay dynamic data in an XML based format.

In my mind (and I could be wrong, LOL sometimes I'm wrong about 67 seconds a minute I feel) once you have that working then it's just making a call to DataGridColumn and changing the style for that specific column.

Let us know what happens! ;-)

Christopher