0
votes

I have the following s:List

<s:List
    id="lstOther"
    borderVisible="false"
    width="100%" height="100%"
    dataProvider="{this.handler.itemRendererType}"
    labelFunction="labelFunction"
    itemRendererFunction="itemRendererFunction">
</s:List>

The functions for itemRendererFunction and labelFunction look like this:

private function itemRendererFunction(item:Object):IFactory {
            var clazz:Class = DefaultItemRenderer;
            switch(item.data) {
                case "Security Unit":
                    clazz = CheckBox;
                    break;
                default:
                    clazz = CheckBoxEditLabel;
            }
            return new ClassFactory(clazz);
        }

        private function labelFunction(item:Object):String {
            return "testing";
        }

My data provider (dataProvider="{this.handler.itemRendererType}") is composed as follows:

public var itemRendererType:ArrayCollection = new ArrayCollection([
        {name:"otherLabel1", data:"Security Unit"},
        {name:"otherLabel2", data:"Test 1"},
        {name:"otherLabel3", data:"Test 2"}
    ]);

I first tried setting labelField in the s:List to 'name'. Nothing showed up in the list control. As can be seen above, I tried using a label function and returning a hard coded value ("testing"). Still nothing shows up.

Why is the text for the labels not showing up?

Any help would be greatly appreciated. Thanks!

3
Can you post the code to your CheckBox and CheckBoxEditLabel renderers?sshongru

3 Answers

0
votes

My immediate guess is that this.handler is null; you should debug to see why that is (what is handler anyways?). You were right about using labelField="name", that should work, but won't show anything if you don't have any data. Also, I'm fairly sure your itemRendererFunction isn't going to work properly since it needs to return a component that extends s:ItemRenderer.

0
votes

this.handler is not null. handler is the actionscript class where the itemRendererType is defined.

0
votes

The following item renderer works fine with your sample:

<?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:CheckBox label="{label}" />
</s:ItemRenderer>