简体   繁体   中英

Flex DropDownList ItemRenderer probably a bug

I am trying to make a simple change on look of Flex 4.5 Spark DropDownLis trough extending it's item renderer, anyway even a just shiny new item renderer bring me as result a items which labels is blanks. If i remove the renderer everything is fine, but with it - the items is blank white.

<s:DropDownList id="cbX" x="140" y="281" width="276" itemRenderer="comboItemRenderer" labelField="@text">
    <mx:XMLListCollection>
        <fx:XMLList>
            <node text="1" />
            <node text="2" />
            <node text="3" />
        </fx:XMLList>
    </mx:XMLListCollection>
</s:DropDownList>

item renderer:

<?xml version="1.0" encoding="utf-8"?>
<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" 
                xmlns:s="library://ns.adobe.com/flex/spark" 
                xmlns:mx="library://ns.adobe.com/flex/mx" 
                autoDrawBackground="true">

    <s:Label text="{data}"/>

</s:ItemRenderer>

Is it a bug, or i am doing it wrong?

Try to use:

<?xml version="1.0" encoding="utf-8"?>
<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" 
                xmlns:s="library://ns.adobe.com/flex/spark" 
                xmlns:mx="library://ns.adobe.com/flex/mx" 
                autoDrawBackground="true">

    <s:Label text="{label}"/>

</s:ItemRenderer>

The data for the renderer is still the data. But if you use labelField you rely on List's label calculation routine. So just display it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM