Perhaps there's a better way to do it, which I'm open to. The setup
is actually based on your blog post. We have a datagrid with an
inline renderer holding the custom list with a custom renderer:
<mx:DataGridColumn textAlign="center" width="25" headerText="Start" >
<mx:itemRenderer>
<mx:Component>
<imake:RichListGridColumn
dataProvider="{data.offerPeriods}"
itemRenderer="com.imake.ui.components.DeepListItemRenderer"
borderThickness="0" targetField="endDate"
nOffers="{data.NOfferPeriods}"/>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
The custom tag passes the name of the field of interest, and germane
to our purpose, the depth of the list.
And in the custom list's renderer we have:
override public function validateProperties():void
{
if (!listData)
{
return super.validateProperties();
}
var ukDisplayDateFmt:DateFormatter=new DateFormatter();
ukDisplayDateFmt.formatString="DD/MM/YYYY";
// Deal with row count in a stateless way
ukDisplayDateFmt.formatString="DD/MM/YYYY";
var listControl:Object = listData.owner as ListBase;
var targetField:String=listControl.targetField;
listData.label=ukDisplayDateFmt.format(data[targetField]);
var n:int = listControl.nOffers;
if (n==0){
listControl.rowCount=1; // ensure space if
somehow depth fails
} else {
listControl.rowCount=n;
}
return super.validateProperties();
}
Is there a better approach, or am I missing something obvious?
--- In [email protected], "Alex Harui" <[EMAIL PROTECTED]> wrote:
>
> I'm not sure I understand the setup. It is rare for a renderer to set
> its parent's rowCount.
>
>
>
> From: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf Of dorsetwest
> Sent: Tuesday, August 26, 2008 6:34 PM
> To: [email protected]
> Subject: [flexcoders] List rowCount in a datagrid, varying by row using
> ListItemRenderer
>
>
>
> Folks ...
>
> I'm implementing a master/detail view in a datagrid column by means of
> a custom component that extends List and uses a programmatic
> listitemrenderer that renders as many rows in the list as the detail
> for that column requires.
>
> It works well ... up to a point. Seems that the first row's list
> depth locks in the depth for all succeeding rows.
>
> I remember reading something in Alex's notes on itemRenderers that
> suggests they are reused extensively. Therefore I've taken care to
> set rowCount carefully each time rendering takes place. However while
> the debugger shows the itemRenderer setting its parent's rowCount
> correctly, the setting has no effect on the visual display, still
> locked at the first row's detail depth.
>
> Anybody have any thoughts as to why this might be happening, and how
> the rowCount of a list in a column can be varied on a per column or
> per row basis?
>
> Also interested in other approaches; tempted by advancedDataGrid, but
> seems very difficult to get working at all (due to some of the
> classloading order bugs) and has a pretty scary list of internal
> issues. Ideas?
>
> R.
>