J'ai une ArrayCollection d'objets. Je passe ce tableau à un horizontalallist en tant que fournisseur de données et j'utilise un itemRenderer personnalisé.Flex-Typed ArrayCollection en tant que dataProvider de Horizontallist
Lors de l'exécution de l'application, le HorizontalList affiche
[object CustomClass][object CustomClass][object CustomClass][object CustomClass]
J'ai essayé casting chaque objet dans le itemRenderer comme suit:
<mx:Label text="{(data as CustomClass).label1}"/>
Mais cela ne fonctionne pas ...
Merci pour toute aide que vous pouvez fournir. Cordialement,
BS_C3
Modifier - 09 Mars 2010
allons-y pour un peu plus de code =)
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Component id="Item">
<mx:VBox width="180">
<mx:HBox width="100%">
<mx:Spacer width="100%"/>
<mx:Button label="x"/>
</mx:HBox>
<mx:Image id="thumbnail"/>
<mx:Label width="100%" horizontalCenter="0" text="Collection"/>
<mx:HBox width="100%">
<mx:Label width="100" text="GIA"/>
<mx:Label text="{data.charg_st}"/>
</mx:HBox>
<mx:HBox width="100%">
<mx:Label width="100" text="Finger Size"/>
<mx:Label text="xxxxxx"/>
</mx:HBox>
<mx:HBox width="100%">
<mx:Label width="100" text="Carat"/>
<mx:Label text="{data.carats}"/>
</mx:HBox>
<mx:HBox width="100%">
<mx:Label width="100" text="Color"/>
<mx:Label text="{data.color}"/>
</mx:HBox>
<mx:HBox width="100%">
<mx:Label width="100" text="Clarity"/>
<mx:Label text="{data.clarity}"/>
</mx:HBox>
<mx:HBox width="100%">
<mx:Label width="100" text="Shop"/>
<mx:Label text="{data.lgort_fp}"/>
</mx:HBox>
<mx:HBox width="100%">
<mx:Label width="100" text="Resizing"/>
<mx:Label text="{data.resizing}"/>
</mx:HBox>
<mx:HBox width="100%">
<mx:Label width="100" text="Price Excl. VAT"/>
<mx:Label text="{data.net_price_fp}"/>
</mx:HBox>
</mx:VBox>
</mx:Component>
<mx:HorizontalList
dataProvider="{GlobalData.instance.tray}"
columnCount="4"
rowCount="1"
horizontalScrollPolicy="off"
itemRenderer="{Item}"
/>
</mx:Canvas>
Pour votre information, le dataprovider horizonalList est un ArrayCollection d'objets.
Maintenant, l'horizontallist affiche des éléments vides ... avec la largeur correcte ... La collection de tableaux n'est pas vide (j'utilise une alerte sur l'événement click sur un élément, et je récupère les données attendues).
Espérons que cela aidera> _ <
Cordialement, BS_C3
Pouvez-vous ajouter plus de code ou un test complet? – Patrick
Personne n'a de solution? J'ai continué à essayer différentes solutions, cela ne fonctionne toujours pas. Tout ce qui est à l'intérieur de l'itemrenderer apparaît "BLANK". C'est comme si l'objet était là, mais quelque chose le cache. J'ai ajouté un événement itemClick pour afficher les données de l'élément, et il affiche ... J'ai également recréé la collection array comme une collection array d'objets ... Et cela ne change pas le comportement de l'horizontalallist. Toujours obtenir un élément vide ... Je ne comprends vraiment pas> _ < Un indice? –