Flex DropDownList LabelFunction 问题
我有一个下拉列表:
<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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不清楚您的问题是下拉列表中只有一个项目还是下拉列表中的所有项目都显示相同的文本;但我写这个答案时假设是前者。
你是在调试模式下运行的吗? labelFunction 被调用了多少次?我认为 labelFunction 在这种情况下是一个转移注意力的东西。如果列表仅显示单个项目,则很可能是因为它认为 dataProvider 仅具有单个项目。
如果您有一个包含三个项目的 dataProvider,则应该调用 labelFunction 3 次。每个项目都会调用一次。
一般来说,如果我不绑定到多个对象,我的绑定体验是最一致的。所以,你这样就可以了:
或者这样
但是,我不希望这能起作用:
所以,我的问题是你确定 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:
or this
But, I would not expect this to work:
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.
好的,我能够使用“
也许对有类似问题的其他人有帮助”来解决它:)
Ok I was able to solve it using
Maybe helpful for others who have similar issues :)