论坛首页 入门技术论坛

Flex CombBox联动使用XML实现

浏览 1382 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2010-03-19  

<?xml version="1.0" encoding="utf-8"?>
<students>
<student name="jimmy" id="111">
  <grade id="math">100</grade>
  <grade id="history">120</grade>
</student>

<student name="lucy" id="222">
  <grade id="arts">130</grade>
  <grade id="biology">140</grade>
</student>
</students>
</countries>

 

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white">
 
    <mx:XML id="dp" source="student_grade.xml" format="e4x" />
   <mx:Script>
    <![CDATA[
     import mx.controls.Alert;
     private function clickHandle():void
     {
      var o:Object = student.selectedItem;
      var s:String = student.selectedItem.@id;
      trace(student.selectedItem.@id);
      
      var oo:Object = grade.selectedItem;
      trace(grade.selectedItem.@id);
     }
    ]]>
   </mx:Script>
    <mx:Form>
        <mx:FormItem label="Student:">
            <mx:ComboBox id="student" dataProvider="{dp.student}" labelField="@name" />
        </mx:FormItem>
        <mx:FormItem label="Grade:">
            <mx:ComboBox id="grade" dataProvider="{student.selectedItem.grade}" />
        </mx:FormItem>
    </mx:Form>
   <mx:Button click="clickHandle()"/>
</mx:Application>

论坛首页 入门技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics