Flex Combox 实现3级联动

<?xml version="1.0" encoding="utf-8"?>
<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="100%" height="100%" title="Add Store" fontWeight="bold" fontSize="13" backgroundColor="#9AEDFF" backgroundAlpha="0.2" borderColor="#7CFFF4" themeColor="#97D7FF">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.collections.ArrayCollection;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
[Bindable]
private var cityList:ArrayCollection ;
[Bindable]
private var countyList:ArrayCollection ;

public function changeHandlerProvice():void{
countyList=null;
var remoteCity:RemoteObject = new RemoteObject("cityDao");
remoteCity.getCityListByPid(this.provice.selectedItem.id);
remoteCity.addEventListener(ResultEvent.RESULT,handleGetCitySuccess);
remoteCity.addEventListener(FaultEvent.FAULT,handleGetDataError);
}
public function changeHandlerCity():void{
var remoteCounty:RemoteObject = new RemoteObject("countyDao");
remoteCounty.getCountyListByCid(this.city.selectedItem.id);
remoteCounty.addEventListener(ResultEvent.RESULT,handleGetCountySuccess);
remoteCounty.addEventListener(FaultEvent.FAULT,handleGetDataError);
}
private function handleGetCitySuccess(event:ResultEvent):void{
cityList= event.result as ArrayCollection;
if(cityList!=null){
city.dataProvider = cityList;
}
}
private function handleGetCountySuccess(event:ResultEvent):void{
countyList= event.result as ArrayCollection;
if(countyList!=null){
county.dataProvider = countyList;
}
}
private function handleGetDataError(event:FaultEvent):void{
Alert.show("访问远程对象错误...","信息提示");
}

private function initCity():void{
var remoteCity:RemoteObject = new RemoteObject("cityDao");
remoteCity.getCityListByPid(1);
remoteCity.addEventListener(ResultEvent.RESULT,handleGetCitySuccess);
remoteCity.addEventListener(FaultEvent.FAULT,handleGetDataError);
var remoteCounty:RemoteObject = new RemoteObject("countyDao");
remoteCounty.getCountyListByCid(1);
remoteCounty.addEventListener(ResultEvent.RESULT,handleGetCountySuccess);
remoteCounty.addEventListener(FaultEvent.FAULT,handleGetDataError);
}

]]>
</mx:Script>
<!--<mx:XML id="areaXml" source="area.xml"/>
<mx:RemoteObject id="srv2" destination="cityDao"/>
-->
<mx:RemoteObject id="pDao" destination="proviceDao"/>

<mx:Form x="10" y="10" width="100%" height="100%">
<mx:FormItem label="Store Name:" width="100%">
<mx:TextInput width="80%"/>
</mx:FormItem>
<mx:FormItem label="Area" id="area" direction="horizontal">
<mx:ComboBox creationComplete="pDao.getAllProviceList()" id="provice" width="100" dataProvider="{pDao.getAllProviceList.lastResult}" labelField="provicename" change="changeHandlerProvice()"/>
<mx:ComboBox id="city" creationComplete="initCity()" width="100" dataProvider="{cityList}" labelField="cityname" change="changeHandlerCity()"/>
<mx:ComboBox width="100" id="county" dataProvider="{countyList}" labelField="countyname"/>
<mx:TextInput width="117" id="town"/>
</mx:FormItem>

</mx:Form>

</mx:Panel>

remote-config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<service id="remoting-service"
class="flex.messaging.services.RemotingService">

<adapters>
<adapter-definition id="java-object"
class="flex.messaging.services.remoting.adapters.JavaAdapter"
default="true" />
</adapters>

<default-channels>
<channel ref="my-amf" />
</default-channels>

<destination id="storeDao">
<properties>
<factory>spring</factory>
<source>storeDao</source>
</properties>
</destination>

<destination id="proviceDao">
<properties>
<factory>spring</factory>
<source>proviceDao</source>
</properties>
</destination>

<destination id="cityDao">
<properties>
<factory>spring</factory>
<source>cityDao</source>
</properties>
</destination>

<destination id="countyDao">
<properties>
<factory>spring</factory>
<source>countyDao</source>
</properties>
</destination>
</service>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值