Flex,& XML:获取 xml 节点来指定数据提供者
我正在尝试设置组合框的数据提供者。 我有 2 个组合框:cb_div 和 cb_stores。 对于 cb_div,我可以使用 XML 文件正确设置数据提供程序。 cb_stores的dataprovider根据cb_div的所选项目进行设置。
首先,这是我的 XML 文件。 cb_div 的数据提供者:
<?xml version="1.0" encoding="UTF-8"?>
<divisions>
<division id="Japan">Japan</division>
<division id="Europe">Europe</division>
</divisions>
cb_stores 的数据提供者:
<list>
<stores name="Europe">
<store>BOUTIQUE HARROD'S</store>
<store>GALERIES LAFAYETTE LILLE</store>
<store>GALERIES LAFAYETTE SAISONNIERE</store>
</stores>
<stores name="Japan">
<store>ODEIS PACK HANZOMON</store>
<store>GINZA</store>
<store>OMOTESANDO</store>
</stores>
</list>
我想做的是以下内容:如果用户在 cb_div 中选择“日本”,则 cb_stores 的数据提供者应该是
,如果他选择“欧洲”,则数据提供者应为
。
这就是我所做的,但它不起作用:它返回每个商店。
<mx:Script>
<![CDATA[
import mx.controls.Alert;
private function division_change():void
{
Alert.show(division.selectedItem.toString());
var temp:XMLList = stores.stores.(@name=division.selectedItem);
store.dataProvider = temp.store;
}
]]>
</mx:Script>
<mx:VBox verticalGap="10">
<mx:ComboBox id="division" dataProvider="{divisions.division}" change="division_change()" prompt=" "/>
<mx:ComboBox id="store" prompt=" "/>
<mx:TextInput id="password" displayAsPassword="true"/>
</mx:VBox>
感谢您提供的任何帮助。
问候
I'm trying to set a combobox's dataprovider.
I have 2 comboboxes: cb_div and cb_stores.
For cb_div, I get to set the data provider correctly with an XML file.
Cb_stores' dataprovider is to be set depending on the selected item of cb_div.
First, here are my XML files.
Data provider for cb_div:
<?xml version="1.0" encoding="UTF-8"?>
<divisions>
<division id="Japan">Japan</division>
<division id="Europe">Europe</division>
</divisions>
Data provider for cb_stores:
<list>
<stores name="Europe">
<store>BOUTIQUE HARROD'S</store>
<store>GALERIES LAFAYETTE LILLE</store>
<store>GALERIES LAFAYETTE SAISONNIERE</store>
</stores>
<stores name="Japan">
<store>ODEIS PACK HANZOMON</store>
<store>GINZA</store>
<store>OMOTESANDO</store>
</stores>
</list>
What I'm trying to do is the following: if the user selects "Japan" in cb_div, the dataprovider of cb_stores should be the stores under <stores name="Japan">
, if he selects "Europe", the dataprovider should be <stores name="Europe">
.
This is what I've done and it's not working: it returns every stores.
<mx:Script>
<![CDATA[
import mx.controls.Alert;
private function division_change():void
{
Alert.show(division.selectedItem.toString());
var temp:XMLList = stores.stores.(@name=division.selectedItem);
store.dataProvider = temp.store;
}
]]>
</mx:Script>
<mx:VBox verticalGap="10">
<mx:ComboBox id="division" dataProvider="{divisions.division}" change="division_change()" prompt=" "/>
<mx:ComboBox id="store" prompt=" "/>
<mx:TextInput id="password" displayAsPassword="true"/>
</mx:VBox>
Thanks for any help you can provide.
Regards
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
立即
需要
注意“==”
的变化,看看还有什么问题。
right off the bat
needs to be
notice the "=="
change that and see what else is going wrong.