There are no stupid questions. :-) I'm glad that you got it working.
The second parameter specifies the DataGrid column. This can be useful
if, for instance, you are using the same labelFunction for several
columns, and you need to conditionally format the returned object;
depending on the column that is using the callback function.
private functiongetLabelUnit( item:Object, column:DataGridColumn) :
Number
{
if (column.headerText == "Sellable Unit1") return
item.CaServiceIds. getItemAt(0);
if (column.headerText == "Sellable Unit2") return
item.CaServiceIds. getItemAt(1);
}
<mx:columns>
<mx:DataGridColumn headerText="Content Name" dataField="ContentName"
width="64" wordWrap="true"/>
<mx:DataGridColumn headerText="Sellable Unit1" labelFunction=
"getLabelUnit" width="63" wordWrap="true"/>
<mx:DataGridColumn headerText="Sellable Unit2" labelFunction=
"getLabelUnit" width="63" wordWrap="true"/>
</mx:columns>
-TH
--- In [email protected], Michelle Davis <[EMAIL PROTECTED]> wrote:
>
> Hi Tim,
> Can I ask you another stupid question? I learned labelFunction from
the web site, I don't understand the second parameter
column:DataGridColumn. What is that for?
> Thanks,
> Michelle.
>
>
>
> ----- Original Message ----
> From: Tim Hoff [EMAIL PROTECTED]
> To: [email protected]
> Sent: Tuesday, August 12, 2008 8:17:39 PM
> Subject: [flexcoders] Re: datagridcolumn
>
>
> Hi Michelle,
> You're on the right track with the labelFunction. Give this a try:
> privatefunctiongetLabelUnit1( item:Object, column:DataGridColu mn) :
Number
> {
> returnitem..CaServiceIds. getItemAt( 0);
> }
> privatefunctiongetLabelUnit2( item:Object, column:DataGridColu mn) :
Number
> {
> returnitem.CaServiceIds. getItemAt( 1);
> }
> <mx:columns>
> <mx:DataGridColumn headerText="Content Name" dataField="ContentName"
width="64" wordWrap="true"/>
> <mx:DataGridColumn headerText="Sellable Unit1" labelFunction=
"getLabelUnit1" width="63" wordWrap="true"/>
> <mx:DataGridColumn headerText="Sellable Unit2" labelFunction=
"getLabelUnit2" width="63" wordWrap="true"/>
> </mx:columns>
> -TH
>
> --- In [EMAIL PROTECTED] ups.com, Michelle Davis mtndavis@ wrote:
> >
> > Hello,
> >
> > I have the following issue and I don't know what to do.
> >
> > My DatagGrid dataProvider is ArrayCollection contains the following
information
> >
> > _1363246720dgCaAsso ciation = mx.controls. DataGrid (@34090a1)
> > mx.controls. dataGridClasses. DataGridBase [inherited] =
> > columnCount = 3 : Number
> > columns = Array (@317af59)
> > dataProvider = webservices. caconfigurator. CaAssociationArr ay
(@3413601)
> > mx.collections. ArrayCollection [inherited] =
> > [0] = webservices. caconfigurator. CaAssociation (@33f3e51)
> > CaServiceIds = webservices. caconfigurator. CaServiceIdArray
(@3413501)
> > mx.collections. ArrayCollection [inherited] =
> > [0] = 242 [0xf2] : Number
> > [1] = 243 [0xf3] : Number
> > ContentName = "cu2" : String
> > Id = 1 : Number
> > RadioStationName = "knx" : String
> >
> >
> >
> > I called DataGridColumn to display ContentName on the first column,
CaServiceIds[ 0] on the second column and CaServiceIds[ 1]on the third
column. But not successful. Please help
> >
> > I tried the following:
> >
> > 1) I used "dataField" in all 3 DataGridColumn.. The first column
displayed "cu2", second column display "242,243" and third column
display "242,243"
> >
> > <mx:columns>
> > <mx:DataGridColumn headerText=" Content Name" dataField="ContentN
ame" width="64" wordWrap="true" />
> > <mx:DataGridColumn headerText=" Sellable Unit1" dataField="CaServic
eIds" width="63" wordWrap="true" />
> > <mx:DataGridColumn headerText=" Sellable Unit2" dataField="CaServic
eIds" width="63" wordWrap="true" />
> > </mx:columns>
> >
> >
> >
> >
> >
> > 2) I used "labelFunction to display CaServiceIds[ 0] and
CaServiceIds[ 1]. I got an error Main Thread (Suspended: Error: Unknown
Property: 'null'.)
> > mx.collections: :ListCollectionV iew/http: //www.adobe. com/2006/
actionscript/ flash/proxy: :getProperty
> > view::RadioStations /getLabelUnit1
> > mx.controls. dataGridClasses: :DataGridColumn/ itemToLabel
> > mx.controls. dataGridClasses: :DataGridBase/ makeListData
> > mx.controls: :DataGrid/ http://www. adobe.com/ 2006/flex/
mx/internal: :setupRendererFr omData
> > mx.controls: :DataGrid/ commitProperties
> > mx.core::UIComponen t/validateProper ties
> > mx.managers: :LayoutManager/ validateProperti es
> > mx.managers: :LayoutManager/ doPhasedInstanti ation
> > Function/http: //adobe.com/ AS3/2006/ builtin:: apply [no source]
> > mx.core::UIComponen t/callLaterDispa tcher2
> > mx.core::UIComponen t/callLaterDispa tcher
> >
> > }privatefunctiondis playSellableUnit (ids:CaServiceId Array,
index:Number) :Number{returnid s.getNumberAt( index)privatefun
ctiongetLabelUni t1(item:Object, column:DataGridColu mn):
Number{sellableUnit 1 = displaySellableUnit (item.CaServiceI ds[column.
dataField] ,0)varsellableUn it1:Number} returnsellableUn it1
> > <mx:columns>
> > <mx:DataGridColumn headerText=" Content Name" dataField="ContentN
ame" width="64" wordWrap="true" />
> > <mx:DataGridColumn headerText=" Sellable Unit1" labelFunction=
"getLabelUnit1" width="63" wordWrap="true" />
> > <mx:DataGridColumn headerText=" Sellable Unit2" labelFunction=
"getLabelUnit2" width="63" wordWrap="true" />
> > </mx:columns>
> >
> > Thanks so much,
> > Michelle - beginner on Flex builder 3
> >
>