浏览 5521 次
锁定老帖子 主题:Flex DataGrid 数据上下移动
该帖已经被评为新手帖
|
|
---|---|
作者 | 正文 |
发表时间:2008-05-14
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:window="com.diaztorres.window.*" xmlns:log="com.log.*"> <mx:Script> <![CDATA[ import mx.collections.IList; import mx.collections.ArrayCollection public function moveUp(event : MouseEvent) : void { var i : int = peopleList.selectedIndex; if (i >= 1&&peopleList.selectedItem) { IList(peopleList.dataProvider).addItemAt(peopleList.selectedItem,i-1); IList(peopleList.dataProvider).removeItemAt(i+1); peopleList.selectedIndex = i; } } public function moveDown(event : MouseEvent) : void { var i : int = peopleList.selectedIndex; if (i < (ArrayCollection(peopleList.dataProvider).length - 1) && peopleList.selectedItem) { IList(peopleList.dataProvider).addItemAt(peopleList.selectedItem,i + 2); IList(peopleList.dataProvider).removeItemAt(i); peopleList.selectedIndex = i; } } ]]> </mx:Script> <mx:VBox horizontalAlign="center" x="618" y="176" height="264"> <mx:DataGrid id="peopleList" x="198" y="66" width="302"> <mx:columns> <mx:DataGridColumn headerText="Name" dataField="name"/> <mx:DataGridColumn headerText="Address" dataField="address"/> </mx:columns> </mx:DataGrid> <mx:ControlBar width="298" autoLayout="true" horizontalAlign="right" height="26"> <mx:Button label="上移" click="moveUp(event)"/> <mx:Button label="下移" click="moveDown(event)"/> </mx:ControlBar> </VBox> </mx:Application> 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2008-05-14
少了</mx:VBox>。如果可以,上传文件最好了
|
|
返回顶楼 | |
发表时间:2008-05-14
ArrayCollection是你自定义还是 :import mx.collections.ArrayCollection;
|
|
返回顶楼 | |
发表时间:2008-05-15
是import mx.collections.ArrayCollection,
给DataGrid赋一下值就可以了 |
|
返回顶楼 | |
发表时间:2009-01-12
var i : int = peopleList.selectedIndex;
if (i < (ArrayCollection(peopleList.dataProvider).length - 1) && peopleList.selectedItem) { IList(peopleList.dataProvider).addItemAt(peopleList.selectedItem,i + 2); IList(peopleList.dataProvider).removeItemAt(i); peopleList.selectedIndex = i; |
|
返回顶楼 | |