views:

571

answers:

2

Hello,

i want to populate a horizontalList component from a xml file, the width value will be inside the xml file as well with all the data.

actually i have this code:

<mx:Model id="epg" source="epg.xml" /> 

<mx:Component id="customRend">
    <mx:Label text="{data.description}" width="{data.width}"/> 
</mx:Component>

<mx:HBox x="82" y="104" width="1203" height="113" verticalAlign="middle">
    <mx:HorizontalList width="100%"  dataProvider="{epg.channel.program}" 
        itemRenderer="{customRend}" horizontalScrollPolicy="off">
    </mx:HorizontalList> 
</mx:HBox>

but it sets same width for all elements in the list.

Do you know how to do this?

Thanks a lot. Br

A: 

Two ways to do this:

  • Set label.width = data.width on creationComplete
  • Wrap Label in Canvas

The creationComplete way (probably because an itemRenderer should be a Container?):

<mx:HorizontalList width="100%" dataProvider="{epg.channel.program}"  horizontalScrollPolicy="off">
    <mx:itemRenderer>
        <mx:Component id="customRend">
            <mx:Label text="{data.description}" creationComplete="this.width = data.width"/> 
        </mx:Component>
    </mx:itemRenderer>
</mx:HorizontalList>

... or wrapped in Canvas:

<mx:HorizontalList width="100%" dataProvider="{epg.channel.program}"  horizontalScrollPolicy="off">
    <mx:itemRenderer>
        <mx:Component id="customRend">
            <mx:Canvas horizontalScrollPolicy="off">
                <mx:Label text="{data.description}" width="{data.width}"/> 
            </mx:Canvas>
        </mx:Component>
    </mx:itemRenderer>
</mx:HorizontalList>

Hope that helps, Lance

viatropos
thanks for your help.i tried this code, but still same issue. The width is always the same for all the elements, i have no hint about this :-(
ignatius
what version of Flex are you using? It's working for me.
viatropos
i have flex builder 3, what i really want to implement is something like this http://jaganath.files.wordpress.com/2006/12/guide.PNG, maybe there is other easier component that i can use ...
ignatius
A: 

Hi,

Did anyone get this to work? I need to have a HorizontalList, but with variable ItemRenderer widths.

I can change the IteRenderer width, but the column width of the HorizontalList remains the same for all columns.

Any help is appreciated.

Regards, Sam

Sam
ignatius