我有一个下拉列表:
<s:DropDownList id="cad" width="100%" dataProvider="{model.referenceList.refPatientResponseLists}"
labelFunction="myFunction" selectedIndex="{model.cd.code}"/>现在refPatientResponseLists返回了3行数据&我需要在下拉列表中显示这3个值。所以我有如下的label函数:
public function myFunction(item:Object):String {
return item['refPatientResponses'] [cad.dataProvider.getItemIndex(item)]['responseDesc']+'';
}但这只在下拉列表中显示1个值。因此,它返回如下内容:
return item['refPatientResponses'] [0] ['responseDesc']+'' 如何获取下拉列表中的所有3个值。希望我的问题是可以理解的,并期待得到答复。
谢谢
哈里什
日志中的对象结构:
(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发布于 2010-10-23 02:55:27
好的,我可以用以下方法解决这个问题:
Model.referenceList.refPatientResponseLists.getItemAt(0).refPatientResponses可能对其他有类似问题的人有帮助:)
发布于 2010-10-19 05:50:58
我不清楚您的问题是您的下拉列表只有一个项目,还是下拉列表中的所有项目都显示相同的文本;但我写这个答案是基于前者。
你在调试模式下运行了吗?labelFunction被调用了多少次?在这种情况下,我认为labelFunction是在转移注意力。如果列表只显示一个项目,很可能是因为它认为dataProvider只有一个项目。
如果您有一个包含三个项目的dataProvider,则应该调用labelFunction三次。它为每一项调用一次。
通常,如果我不绑定到多个对象,我的绑定体验是最一致的。所以,你这样做是可以的:
model.referenceList或者这个
referenceList.refPatientResponseLists但是,我不认为这是可行的:
model.referenceList.refPatientResponseLists所以,我的问题是,您确定在dataProvider中返回了三个项目吗?您确定组件知道您的dataProvider中有三个项目(AKA正在正确更新绑定)吗?
在不了解对象结构的情况下,很难调试labelFunction,但是不应该使用getItemIndex函数。
https://stackoverflow.com/questions/3963525
复制相似问题