[Flex] PopUpButton系列 —— 将DataGrid作为弹出内容
<?xml version="1.0" encoding="utf-8"?> <!--Flex中如何创建一个可以弹出DataGrid作为菜单的PopUpButton的例子 PopUpButtonDataGrid.mxml--> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"> <fx:Script> <![CDATA[ import mx.collections.ArrayCollection; ]]> </fx:Script> <fx:Declarations> <!-- 将非可视元素(例如服务、值对象)放在此处 --> <fx:Array id="arr"> <fx:Object label="《霹雳先锋》香港票房8916612" actor="Steven Chow"/> <fx:Object label="《捕风汉子》香港票房3149395" actor="Steven Chow"/> <fx:Object label="《小偷阿星》香港票房7968106 " actor="Steven Chow"/> <fx:Object label="笑傲江湖之东方不败(1992)" actor="Jet Li"/> <fx:Object label="精武英雄(1994)" actor="Jet Li"/> <fx:Object label="给爸爸的信(1995)" actor="Jet Li"/> </fx:Array> </fx:Declarations> <fx:Style> @namespace s "library://ns.adobe.com/flex/spark"; @namespace mx "library://ns.adobe.com/flex/mx"; mx|PopUpButton { popUpStyleName: myCustomPopUpStyleName; } .myCustomPopUpStyleName { fontWeight: normal; textAlign: left; } </fx:Style> <mx:PopUpButton id="popUpButton" label="Click to open..." openAlways="true"> <mx:popUp> <!--<mx:DataGrid dataProvider="{arr}" draggableColumns="true" rowCount="4" width="400"> <mx:columns> <mx:DataGridColumn dataField="label" headerText="workers:" /> <mx:DataGridColumn dataField="actor" headerText="actors:" /> </mx:columns> </mx:DataGrid>--> <s:DataGrid dataProvider="{new ArrayCollection(arr)}" height="100" width="400" > <s:columns> <s:ArrayList> <s:GridColumn dataField="label" headerText="workers:"/> <s:GridColumn dataField="actor" headerText="actors:"/> </s:ArrayList> </s:columns> </s:DataGrid> </mx:popUp> </mx:PopUpButton> </s:Application>
------------------------------------------------------------------
Always put yourself in the other's shoes.If you feel that it hurts you,it probably hurts others,too.------------------------------------------------------------------