thanks for the clarification ...very useful advice.
--- In flexcoders@yahoogroups.com, "Tracy Spratt" <tr...@...> wrote:
>
> Yes, as Beau says.
>
>
>
> One general clarification, the dataField property will only accept a string,
> never an expression (array1[0] is an expression). Similarly, you cannot
> "dot.down" in a dataField, like "myVO.myProperty" that is also an
> expression. To use the dataField, yu must be able to provide a reference to
> a first level property, including in an xml node, either an arttribute
> (@myAttribute) or first level child node.
>
>
>
> And one caution, Array (and XMLList) does not support binding. It will work
> once, on initialize, but if you programmatically change the Array, the bound
> control will not update. Use XML or one of the collections if you need to
> update the dataProvider at run-time.
>
>
>
> Tracy Spratt,
>
> Lariat Services, development services available
>
> _____
>
> From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
> Behalf Of Beau Scott
> Sent: Friday, August 28, 2009 10:44 AM
> To: flexcoders@yahoogroups.com
> Subject: Re: [flexcoders] DatagridColumn dataField question
>
>
>
>
>
> dataField is a property belonging to the objects within the datagrid's
> dataprovider. you don't access the array directly from your datagrid column,
> rather you just name the field to access. So in the case you gave of an
> array of strings, you'd only be able to display properties of the string
> objects themselves (such as length):
>
> <mx:DataGridColumn dataField="length"/> <!-- would display the length of the
> string in each index -->
>
> You could use label function to just return the value of the object as well:
>
> <mx:DataGridColumn labelFunction="{function(... rest):String{return rest[0]
> as String;}}" /> <!-- Will display the actual value of the string at the
> index's row.
>
> However if you make it an array of arrays of strings, you can most certain
> bind columns to indexes of the arrays of strings for display:
>
> <?xml version="1.0" encoding="utf-8"?>
> <mx:WindowedApplication xmlns:mx="http://www.adobe.
> <http://www.adobe.com/2006/mxml> com/2006/mxml" layout="absolute">
> <mx:Script>
> <![CDATA[
> [Bindable]
> public var dp:Array = [
> ['1','2','3'],
> ['a', 'b', 'c']
> ];
> ]]>
> </mx:Script>
> <mx:DataGrid width="100%" dataProvider="{dp}">
> <mx:columns>
> <mx:DataGridColumn dataField="0" /> <!-- Binds to dp[row][0]
> --->
> <mx:DataGridColumn dataField="1" /> <!-- Binds to dp[row][1]
> --->
> <mx:DataGridColumn dataField="2" /> <!-- Binds to dp[row][2]
> --->
> </mx:columns>
> </mx:DataGrid>
> </mx:WindowedApplication>
>
>
> Beau
>
> On Fri, Aug 28, 2009 at 5:28 AM, bhaq1972 <mbha...@hotmail.
> <mailto:mbha...@...> com> wrote:
>
>
>
> Can the dataField reference an array position eg
>
> var array1:Array = ["hello", "world", "etc"];
>
> ...
>
> <mx:DataGridColumn dataField="array1[1]" />
>
> at the moment the only way i can make this work is use a labelFunction
> eg
> <mx:DataGridColumn dataField="array1[1]" labelFunction="something"/>
>
> Just wondered if there was any other way?
>
> TIA
> Bod
>
>
>
>
> --
> Beau D. Scott
> Software Engineer
>