创建可编辑的list 组件

发布于,归属于flex实例沙发还空着,抢! 共有185人围观    

listexample

源代码:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
  3.     <mx:Style>
  4.         Application{
  5.             fontSize:12px;
  6.         }
  7.     </mx:Style>
  8.     <mx:Script>
  9.         <![CDATA[
  10.             [Bindable]
  11.             private var db:Array = [{id:'1',name:'jquery教程'},
  12.                                     {id:'2',name:'ext教程'},
  13.                                     {id:'3',name:'flex教程'}];
  14.             private function editEnd(event:Event):void{
  15.                     trace(list.selectedItem.id+''+list.selectedItem.name);               
  16.             }
  17.             private function setEditor():void{
  18.                 list.editedItemPosition = {columnIndex:0,rowIndex:1};
  19.             }
  20.         ]]>
  21.     </mx:Script>
  22.     <mx:Button label="设置编辑" click="setEditor()" />
  23.     <mx:List width="200" selectedIndex="1" id="list" selectionColor="#CCCCFF" labelField="name" dataProvider="{db}"
  24.          editable="true" itemEditBegin="trace(list.editedItemPosition)" itemEditEnd="editEnd(event)" editorXOffset="5" editorYOffset="2"  x="0" y="30"/>
  25. </mx:Application>

关键点说明:

将list 组件的editable 属性设置为true 并侦听itemEditBegin 和itemEditEnd 属性,或通过包含columnIndex 和rowIndex 属性的对象来设置editedItemPosition。

(如果您喜欢这篇教程,可以通过支付宝打赏我们1元哦,拜谢!)

跟作者说两句

:wink: :twisted: :roll: :oops: :mrgreen: :lol: :idea: :evil: :cry: :arrow: :?: :-| :-x :-o :-P :-? :) :( :!: 8-O 8)