如何将 xml 节点值绑定到 Flex 中的下拉数据字段?
可能是一个新手问题,但在浏览网络后,仍然找不到答案...我有一个像这样的 XML 对象:
<questionpools>
<questionpool id="1">
<name>Sample test bank</name>
<description>This is a Sample test bank description</description>
<createdate>2010.10.10</createdate>
<moddate>2010.10.11</moddate>
<createdby>testuser</createdby>
<modby>testuser</modby>
</questionpool>
<questionpool id="2">
<name>alme</name>
<description>newpool</description>
<createdate>2010.10.31</createdate>
<moddate>2010.10.31</moddate>
<createdby>testuser</createdby>
<modby>testuser</modby>
</questionpool>
<questionpool id="9">
<name>pool_new</name>
<description>newpool</description>
<createdate>2010.10.31</createdate>
<moddate>2010.10.31</moddate>
<createdby>testuser</createdby>
<modby>testuser</modby>
</questionpool>
我将此文件加载到 XML 变量:
var poolMenuXML:XMLList = questionpoolsXML.questionpools;
poolMenu = new XMLListCollection(poolMenuXML.children());
并将“名称”节点绑定到下拉列表的标签字段,
<s:DropDownList id="s_poolnumber" dataProvider="{poolMenu}" labelField="name"></s:DropDownList>
但如何将 id 属性添加为下拉列表的“数据”字段,以便在选择某个项目时返回该字段?
我应该创建一个使用 @id 属性作为“数据”值源的自定义组件吗? (我还尝试添加一个节点,认为这可能会有所帮助,但不幸的是这也不起作用......)
谢谢 彼得
probably a newbie question, but after looking through the 'net, still cannot find an answer... I have an XML object like this:
<questionpools>
<questionpool id="1">
<name>Sample test bank</name>
<description>This is a Sample test bank description</description>
<createdate>2010.10.10</createdate>
<moddate>2010.10.11</moddate>
<createdby>testuser</createdby>
<modby>testuser</modby>
</questionpool>
<questionpool id="2">
<name>alme</name>
<description>newpool</description>
<createdate>2010.10.31</createdate>
<moddate>2010.10.31</moddate>
<createdby>testuser</createdby>
<modby>testuser</modby>
</questionpool>
<questionpool id="9">
<name>pool_new</name>
<description>newpool</description>
<createdate>2010.10.31</createdate>
<moddate>2010.10.31</moddate>
<createdby>testuser</createdby>
<modby>testuser</modby>
</questionpool>
I load this file to an XML variable:
var poolMenuXML:XMLList = questionpoolsXML.questionpools;
poolMenu = new XMLListCollection(poolMenuXML.children());
and bind the 'name' node to a dropdown's label field
<s:DropDownList id="s_poolnumber" dataProvider="{poolMenu}" labelField="name"></s:DropDownList>
but how to add the id attribute as the 'data' field of the dropdown so when an item is selected, it returns that field?
Shall I create a custom component that uses the @id attribute as the source of the 'data' values? (I've also tried to add a node thinking that might help but unfortunately that does not work either...)
thanks
peter
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
稍后传递整个对象并获取 id 属性。请参阅 onDropDownListChange 方法
Pass whole object and fetch id attribute later. See onDropDownListChange method