Question

I have a dropdown list as :

    <s:DropDownList id="cad" width="100%" dataProvider="{model.referenceList.refPatientResponseLists}" 
labelFunction="myFunction"                              selectedIndex="{model.cd.code}"/>

Now the refPatientResponseLists returns 3 rows of data & I need to display the 3 values in the Dropdownlist. So I have the label function as :

    public function myFunction(item:Object):String {
     return item['refPatientResponses'] [cad.dataProvider.getItemIndex(item)]['responseDesc']+''; 
}

But this displays only 1 value in the Dropdownlist. So it returns something like:

return item['refPatientResponses'] [0] ['responseDesc']+'' 

How can I get all the 3 values in the dropdown. Hope my question is understandable and expecting a reply.

Thanks

Harish

Object structure from the logs:

(Typed Object #1 'datacollection.model.ReferenceList')
    (Array #3)
    refPatientResponseLists = (Externalizable Object #4 'flex.messaging.io.ArrayCollection')
      (Array #5)
        [0] = (Typed Object #6 'datacollection.model.RefPatientResponseList')
          refPatientResponses = (Externalizable Object #7 'flex.messaging.io.ArrayCollection')
            (Array #8)
              [0] = (Typed Object #9 'datacollection.model.RefPatientResponse')
                responseSequence = 1
                responseDesc = "No"
                responseCode = 28
                responseTypeCode = 10
              [1] = (Typed Object #10 'datacollection.model.RefPatientResponse')
                responseSequence = 2
                responseDesc = "Yes"
                responseCode = 29
                responseTypeCode = 10
              [2] = (Typed Object #11 'datacollection.model.RefPatientResponse')
                responseSequence = 3
                responseDesc = "Claim Not Found"
                responseCode = 30
                responseTypeCode = 10
Was it helpful?

Solution 2

Ok I was able to solve it using

Model.referenceList.refPatientResponseLists.getItemAt(0).refPatientResponses

Maybe helpful for others who have similar issues :)

OTHER TIPS

I'm unclear if your issue is that your drop down list only has a single item or that all items in the drop down list are displaying the same text; but I wrote this answer assuming the former.

Did you run in debug mode? How many times is the labelFunction being called? I think the labelFunction is a red herring in this case. If the list only shows a single item, it is most likely because it thinks the dataProvider only has a single item.

The labelFunction should be called 3 times if you have a dataProvider w/ three items. It is called once for each item.

Generally, my binding experience is most consistent if I do not bind into multiple objects. So, you this would be okay:

model.referenceList

or this

referenceList.refPatientResponseLists

But, I would not expect this to work:

model.referenceList.refPatientResponseLists

So, the question I have is are you sure that three items are being returned in the dataProvider? Are you sure that the component knows that three items are in your dataProvider (AKA Is Binding properly updating)?

Without knowing your object structure, it is hard to debug your labelFunction, but you shouldn't need to use the getItemIndex function.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top