Just a guess looking at the Flash code (if someone could confirm in the REAL Flex classes which I haven't got).
 
- it seems mx.controls.listclasses.SelectableRow has it's owner property set when it's created to know scope.  This scope is used to call labelFunction.
- SelectableRow is the default cellRenderer for ScrollSelect list, which DataGrid extends.  SelectableRow creates rows using ScrollSelectList by default for the cellRenderer, which he sets the owner to this, the DataGrid
- since the DataGrid's labelFunction property is already set, when the SelectableRow is looking for a label, and calls labelFunction on the DataGrid, it's really doing: theDataGrid.labelFunction(object)
 
Now, since Flex changes this, so for DataGrids you also get the columnName, I'm thinking that change might of not been tested heavily with DataGrids in ViewStacks.
 
Either that, or I'm missing something horribly obvious.
 
Anyone have a mx.controls.listclasses.SelectableRow.as file to send me for Flex so I can see?
 
 
----- Original Message -----
From: JesterXL
Sent: Tuesday, May 17, 2005 4:57 PM
Subject: Re: [flexcoders] DataGrid.labelFunction

Can someone explain why this doesn't work with the labelFunction?
 
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml">
<mx:Script>
<![CDATA[
 
import mx.utils.Delegate;
 
function test(item, colName)
{
 return "cow";
}
 
function doStuff()
{
 var d = view.getChildAt(0);
 //d.datagrid1.labelFunction = Delegate.create(this, test);
 d.datagrid1.labelFunction = test;
}
 
function traceIt()
{
 var d = view.getChildAt(0);
 d.datagrid1.dataProvider = [{col1: "sup", col2: "g money"}];
}
 
]]>
</mx:Script>
<mx:Button label="Label Function" click="doStuff();" />
<mx:Button label="Set Dataprovider" click="traceIt();" />
<mx:ViewStack id="view" creationPolicy="all">
  <mx:VBox id="myVB">
   <mx:DataGrid id="datagrid1">
    <mx:columns>
      <mx:Array>
        <mx:DataGridColumn headerText="Column 1" columnName="col1" />
        <mx:DataGridColumn headerText="Column 2" columnName="col2" />
      </mx:Array>
    </mx:columns>
  </mx:DataGrid>
  </mx:VBox>
  </mx:ViewStack>
</mx:Application>


Yahoo! Groups Links

Reply via email to