Flex DropDownList LabelFunction 问题

发布于 2024-09-28 00:57:53 字数 1809 浏览 1 评论 0原文

我有一个下拉列表:

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

现在 refPatientResponseLists 返回 3 行数据 &我需要在下拉列表中显示 3 个值。所以我的标签函数为:

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

但这在下拉列表中仅显示 1 个值。所以它返回类似这样的内容:

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

我怎样才能获得下拉列表中的所有 3 个值。希望我的问题可以理解并期待得到答复。

感谢

Harish

日志中的对象结构:

(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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

花开半夏魅人心 2024-10-05 00:57:53

我不清楚您的问题是下拉列表中只有一个项目还是下拉列表中的所有项目都显示相同的文本;但我写这个答案时假设是前者。

你是在调试模式下运行的吗? labelFunction 被调用了多少次?我认为 labelFunction 在这种情况下是一个转移注意力的东西。如果列表仅显示单个项目,则很可能是因为它认为 dataProvider 仅具有单个项目。

如果您有一个包含三个项目的 dataProvider,则应该调用 labelFunction 3 次。每个项目都会调用一次。

一般来说,如果我不绑定到多个对象,我的绑定体验是最一致的。所以,你这样就可以了:

model.referenceList

或者这样

referenceList.refPatientResponseLists

但是,我不希望这能起作用:

model.referenceList.refPatientResponseLists

所以,我的问题是你确定 dataProvider 中返回了三个项目吗?您确定该组件知道您的 dataProvider 中有三个项目(又名绑定是否正确更新)?

如果不知道对象结构,则很难调试 labelFunction,但您不需要使用 getItemIndex 函数。

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.

深空失忆 2024-10-05 00:57:53

好的,我能够使用“

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

也许对有类似问题的其他人有帮助”来解决它:)

Ok I was able to solve it using

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

Maybe helpful for others who have similar issues :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文