Mega Code Archive

 
Categories / Flex / Grid
 

Inline DataGrid Editor

<!-- Code from Flex 4 Documentation "Using Adobe Flex 4". This user guide is licensed for use under the terms of the Creative Commons Attribution  Non-Commercial 3.0 License.  This License allows users to copy, distribute, and transmit the user guide for noncommercial  purposes only so long as    (1) proper attribution to Adobe is given as the owner of the user guide; and    (2) any reuse or distribution of the user guide contains a notice that use of the user guide is governed by these terms.  The best way to provide notice is to include the following link.  To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ -->     <!-- itemRenderers\inline\InlineDGEditorCBReUse.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"     width="700">     <fx:Script>                    import mx.collections.ArrayCollection;          [Bindable]          public var initDG:ArrayCollection = new ArrayCollection([              {Company: 'Acme', Contact: 'Bob Jones',Phone: '413-555-1212', City: 'Boston', State: 'MA'},              {Company: 'Allied', Contact: 'Jane Smith',Phone: '617-555-3434', City: 'SanFrancisco', State: 'CA'}          ]);          [Bindable]          public var initDG2:ArrayCollection = new ArrayCollection([              {Company: 'MyCo', Contact: 'Stan Stanley',Phone: '413-555-5555', City: 'Boston', State: 'MA'},              {Company: 'YourCo', Contact: 'Dave Davis',Phone: '617-555-1212', City: 'SanFrancisco', State: 'CA'}          ]);             </fx:Script>     <fx:Declarations>         <fx:Component id="inlineEditor">             <mx:ComboBox>                 <mx:dataProvider>                     <fx:String>AL</fx:String>                     <fx:String>AK</fx:String>                     <fx:String>AR</fx:String>                     <fx:String>CA</fx:String>                     <fx:String>MA</fx:String>                 </mx:dataProvider>             </mx:ComboBox>         </fx:Component>     </fx:Declarations>     <mx:DataGrid id="myGrid" variableRowHeight="true"         dataProvider="{initDG}" editable="true">         <mx:columns>             <mx:DataGridColumn dataField="Company" editable="false" />             <mx:DataGridColumn dataField="Contact" />             <mx:DataGridColumn dataField="Phone" />             <mx:DataGridColumn dataField="City" />             <mx:DataGridColumn dataField="State" width="150"                 editorDataField="selectedItem" itemEditor="{inlineEditor}" />         </mx:columns>     </mx:DataGrid>     <mx:DataGrid id="myGrid2" variableRowHeight="true"         dataProvider="{initDG2}" editable="true">         <mx:columns>             <mx:DataGridColumn dataField="Company" editable="false" />             <mx:DataGridColumn dataField="Contact" />             <mx:DataGridColumn dataField="Phone" />             <mx:DataGridColumn dataField="City" />             <mx:DataGridColumn dataField="State" width="150"                 editorDataField="selectedItem" itemEditor="{inlineEditor}" />         </mx:columns>     </mx:DataGrid> </s:Application>