Mega Code Archive

 
Categories / Flex / Components
 

Inline DataGrid CheckBox 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\InlineDGCheckBoxEditor.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="650">     <fx:Script>            import mx.collections.ArrayCollection;      [Bindable]      private var initDG:ArrayCollection = new ArrayCollection([          {Company: 'Acme', Contact: 'Bob Jones', Phone: '413-555-1212', Date: '5/5/05' , FollowUp: true },          {Company: 'Allied', Contact: 'Jane Smith', Phone: '617-555-3434', Date: '5/6/05' , FollowUp: false}      ]);          </fx:Script>         <mx:DataGrid id="myGrid" dataProvider="{initDG}" editable="true">         <mx:columns>             <mx:DataGridColumn dataField="Company" editable="false" />             <mx:DataGridColumn dataField="Contact" />             <mx:DataGridColumn dataField="Phone" />             <mx:DataGridColumn dataField="Date" />             <mx:DataGridColumn dataField="FollowUp" width="150"                 headerText="Follow Up?" editorDataField="cbSelected">                 <mx:itemEditor>                     <fx:Component>                         <mx:VBox backgroundColor="yellow">                             <fx:Script>                                                                       // Define a property for returning                                      // the new value to the cell.                                      [Bindable]                                      public var cbSelected:Boolean;                                                                 </fx:Script>                             <mx:CheckBox id="followUpCB"                                 label="Follow up needed" height="100%" width="100%"                                 selected="{data.FollowUp}"                                 click="cbSelected=followUpCB.selected" />                         </mx:VBox>                     </fx:Component>                 </mx:itemEditor>             </mx:DataGridColumn>         </mx:columns>     </mx:DataGrid> </s:Application>