views:

44

answers:

2

Hi All

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
A: 

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.

www.Flextras.com
Harish
What logs does that object structure come from? My intuition is that you are incorrectly drilling down into the components in the labelFunction. The getItemIndex usage there just strikes me as bizarre.
www.Flextras.com
The logs are when we set the logging level to debug in the services-config.xml. I understand the getItemIndex usage is not right. I just want the label function to be called 3 times and then get the responseDesc for each row and display it on the dropdownlist. But it appears to be calling the function only once even-though there are 3 rows. Is there a better way of doing this. Please let me know.
Harish
Did you run in debug mode, with a breakpoint in the label function? I find it hard to believe the label function getting called 3 times if your DropDownList's dataProvider has three items in it. I am more likely to believe that the labelFunction is returning the same value each time.
www.Flextras.com
Jeffry, I ran it in debug mode, and the item in function myFunction(item:Object) has an arrayCollection "refPatientResponses" which has a length of 3 and holds 3 objects (RefPatientResponse). Now I want to display 1 of the fields of these 3 objects in the dropdownlist. How can I acheive this? Any ideas please. Thanks
Harish
Also this issue is similar to http://stackoverflow.com/questions/3660479/flex-dropdownlist-does-not-show-the-correct-values that you were able to provide an solution. The only difference now is that I have another arraycollection within the arraycollection instead of an object.
Harish
Give me a some code I can cut and paste into Flash Builder and I'll take a look. Or hire me ( www.asktheflexpert.com )and we can screen share to find a solution.
www.Flextras.com
Ok I was able to solve it using Model.referenceList.refPatientResponseLists.getItemAt(0).refPatientResponses :)
Harish
Glad you figured out. Be sure to mark an answer. Either by selecting my answer or entering a new answer yourself and selecting that.
www.Flextras.com
A: 

Ok I was able to solve it using Model.referenceList.refPatientResponseLists.getItemAt(0).refPatientResponses

Maybe helpful for others who have similar issues :)

Thanks

Harish

Harish