Saturday, August 29, 2009

Using checkbox in datagrid (itemRenderer, itemEditor)

Hi, this post will be about using itemRenderer in flex 3. I'll show, what it's easy on simply example.
I create two files
1. Example.mxml as main application
2. ActionCheckBox as Flex Component

First file (Example.mxml) include:

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init();">
<mx:Script>
<![CDATA[
import mx.controls.CheckBox;

private var collection:Array;

private function init():void{

   collection = new Array();

   collection.push({name:"Paul", active:true});
   collection.push({name:"Erick", active:false});
   collection.push({name:"Margaret", active:true});
   collection.push({name:"Claudia", active:true});
   dataGrid.dataProvider = collection;

}

]]>

</mx:Script>

<mx:DataGrid allowMultipleSelection="true" id="dataGrid" rowHeight="26" editable="true" resizableColumns="true" right="10" left="10" top="10" bottom="111" fontSize="10" fontFamily="Verdana" borderThickness="1" textAlign="center">

   <mx:columns>
      <mx:DataGridColumn headerText="Name" dataField="name"/>
      <mx:DataGridColumn headerText="Active" dataField="active" itemRenderer="ActionCheckBox"  itemEditor="mx.controls.CheckBox"/>
   </mx:columns>

</mx:DataGrid>

</mx:Application>


Second file (ActionCheckBox.mxml):

<?xml version="1.0"?>

<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.core.Application;
]]>
</mx:Script>
<mx:CheckBox height="100%" width="100%" enabled="false" selected="{data.active}"/>
</mx:VBox>

Lokaty bankowe
Nowy podatek vat

No comments:

Post a Comment