Flex中如何允许List或DataGrid控件中同时选中多个项目的例子

By Minidxer | December 5, 2008

接下来的例子演示了Flex中如何允许List或DataGrid控件中同时选中多个项目。

让我们先来看一下Demo可以右键View Source或点击这里察看源代码):


下面是完整代码(或点击这里察看):

Download: main.mxml
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
  3.         layout="horizontal"
  4.         verticalAlign="middle"
  5.         backgroundColor="white">
  6.  
  7.     <mx:Array id="arr">
  8.         <mx:Object col1="One.1" col2="One.2" col3="One.3" />
  9.         <mx:Object col1="Two.1" col2="Two.2" col3="Two.3" />
  10.         <mx:Object col1="Three.1" col2="Three.2" col3="Three.3" />
  11.         <mx:Object col1="Four.1" col2="Four.2" col3="Four.3" />
  12.         <mx:Object col1="Five.1" col2="Five.2" col3="Five.3" />
  13.         <mx:Object col1="Six.1" col2="Six.2" col3="Six.3" />
  14.         <mx:Object col1="Seven.1" col2="Seven.2" col3="Seven.3" />
  15.         <mx:Object col1="Eight.1" col2="Eight.2" col3="Eight.3" />
  16.     </mx:Array>
  17.  
  18.     <mx:ApplicationControlBar dock="true">
  19.         <mx:Form styleName="plain">
  20.             <mx:FormItem label="allowMultipleSelection:">
  21.                 <mx:CheckBox id="checkBox" selected="true" />
  22.             </mx:FormItem>
  23.         </mx:Form>
  24.     </mx:ApplicationControlBar>
  25.  
  26.     <mx:List id="list"
  27.             allowMultipleSelection="{checkBox.selected}"
  28.             dataProvider="{arr}"
  29.             labelField="col1"
  30.             verticalScrollPolicy="on" />
  31.  
  32.     <mx:DataGrid id="dataGrid"
  33.             allowMultipleSelection="{checkBox.selected}"
  34.             dataProvider="{arr}"
  35.             verticalScrollPolicy="on" />
  36.  
  37. </mx:Application>
代码:Peter deHaan 翻译/整理/编译:中文Flex例子

Topics: DataGrid, List | No Comments » | 1,655 views Tags: , , ,

Search Posts