I m trying to add a textInput in the datagrid so that users can see that there is a textbox for them to edit. I have a textInputRender so that I can show the textbox in the dataGrid and update the value accordingly.
I also have another dataGrid table to capture the values I have selected in the previous dataGrid table.
The problem is I am able to see the textbox in the dataGrid table. But I have to double click the cell and enter my value to save the value of the cell in the dataGrid back to the data provider.In reality the user will not double click to enter as they might just enter the value in. Is there a way to capture the value without double clicking the cell ??
Next problem after I double click the textBox and enter my new value for the quantity it do not reflect the change in the textbox. But however I can see that the newly entered value is captured.
Pls help me. I have been sruggling with this for very long. Pls can u tell me how I can slove this ?
This is my custom renderer of the textbox I place it within the GridItemRenderer tags :
<s:TextInput id="ti" text="{data.quant}"/>
This is my code:
<fx:Script>
<![CDATA[
import FrontEndObjects.ColourItems;
import mx.collections.ArrayCollection;
import spark.events.IndexChangeEvent;
[Bindable]
private var order:ArrayCollection = new ArrayCollection();
private function addOrder():void{
var orderItems:ColourItems = new ColourItems("OrderNo","1","--Choose a colour--");
order.addItem(orderItems);
}
[Bindable]
private var confirmOrder:ArrayCollection = new ArrayCollection();
protected function saveData(event:MouseEvent):void
{
//dataGrid is the id (name) of our dataGrid table
var dataProvider = myDG.dataProvider;
var item = null;
for (var i:int = 0; i < dataProvider.length; i++)
{
item = dataProvider.getItemAt(i);
confirmOrder.addItem(item);
//Alert.show("the data is : " + item);
}
}
]]>
</fx:Script>
<s:BorderContainer x="240" y="50" width="449" height="518">
<s:DataGrid id="myDG" x="32" y="27" width="393" height="151" dataProvider="{order}"
editable="true" variableRowHeight="true">
<s:columns>
<s:ArrayList>
<s:GridColumn dataField="label1" headerText="Order #" editable="false"/>
<s:GridColumn dataField="quant" headerText="Qty" editable="true" itemRenderer="DesignItemRenderer.myTextInputRender"/>
<s:GridColumn dataField="color" headerText="Color" editable="true" rendererIsEditable="true">
<s:itemRenderer>
<fx:Component>
<s:GridItemRenderer>
<fx:Script>
<![CDATA[
import spark.events.IndexChangeEvent;
protected function onCbChange(event:IndexChangeEvent):void
{
var value:String = (event.currentTarget as DropDownList).selectedItem;
data[column.dataField] = value;
}
]]>
</fx:Script>
<s:DropDownList id="cb" width="100%" change="onCbChange(event)" prompt="--Choose a colour--"> <!--selectedIndex="0" requireSelection="true" >-->
<s:dataProvider>
<s:ArrayCollection>
<fx:String>red</fx:String>
<fx:String>blue</fx:String>
<fx:String>green</fx:String>
</s:ArrayCollection>
</s:dataProvider>
</s:DropDownList>
</s:GridItemRenderer>
</fx:Component>
</s:itemRenderer>
</s:GridColumn>
</s:ArrayList>
</s:columns >
</s:DataGrid>
<s:DataGrid id="myDG1" x="24" y="317" width="401" height="174" dataProvider="{confirmOrder}"
requestedRowCount="4">
<s:columns>
<s:ArrayList>
<s:GridColumn dataField="label1" headerText="Ordernum - getback"></s:GridColumn>
<s:GridColumn dataField="quant" headerText="quanty-getback"></s:GridColumn>
<s:GridColumn dataField="color" headerText="color-getback"></s:GridColumn>
</s:ArrayList>
</s:columns>
</s:DataGrid>
<s:Button x="355" y="186" label="add" click="addOrder()" />
<s:Button x="277" y="186" label="save" click="saveData(event)"/>
</s:BorderContainer>
Try this:
Set rendererIsEditable="true" in your GridColumn "quant"
<s:GridColumn dataField="quant" headerText="Qty" editable="true" rendererIsEditable="true" itemRenderer="DesignItemRenderer.myTextInputRender"/>
Change your ItemRenderer like this
<?xml version="1.0" encoding="utf-8"?>
<s:GridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
clipAndEnableScrolling="true">
<fx:Binding source="ti.text" destination="data.quant"/>
<s:TextInput
id="ti"
text="{data.quant}"
editable="true"/>
</s:GridItemRenderer>
It works by me fine
I can't recognize which is the problem with your code anyway I managed to develop a:
textInput in the datagrid so that users can see that there is a
textbox for them to edit
Using this code
<mx:DataGrid id="weekGrid" width="100%" height="60%"
dataProvider="{weekList}" editable="true">
<mx:DataGridColumn id="noteColumn" dataField="note" editable="false"
headerText="Note" sortable="false">
<mx:itemRenderer>
<fx:Component>
<mx:VBox width="100%" height="100%" horizontalAlign="center"
verticalAlign="middle">
<fx:Script>
<![CDATA[
import managers.StraordinariManager;
import spark.events.TextOperationEvent;
protected function textinput1_changeHandler(event:TextOperationEvent):void
{
data['note']=textInput.text;
outerDocument.notSavedAlert.statrtBlinker();
}
]]>
</fx:Script>
<s:TextInput id="textInput" width="100%" height="100%"
borderVisible="false"
change="textinput1_changeHandler(event)"
editable="{data.oreStr!=null}"
text="{data.oreStr!=null?data.note:''}">
</s:TextInput>
</mx:VBox>
</fx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:DataGrid>
I used an ItemRenderer instead of a ItemEditor to avoid the double click problem.
Notice that the column editable property is set to false, but the grid is set to editable="true".
I also used the same tecnique to insert also different components, this is an example using the radio button:
<mx:DataGridColumn id="flag" headerText="Approva Rifiuta" >
<mx:itemRenderer>
<fx:Component>
<mx:HBox width="100%" height="100%" horizontalAlign="center"
verticalAlign="middle">
<fx:Script>
<![CDATA[
import managers.IngressiManager;
import mx.events.FlexEvent;
protected function radiobutton1_changeHandler(event:Event):void
{
if(apprRb.selected){
data['flag']=ApprovazioneStraordinariView.APPROVA_FLAG;
data['note']="";
}else
if(rifRb.selected){
data['flag']=ApprovazioneStraordinariView.RIFIUTA_FLAG;
}
}
]]>
</fx:Script>
<s:RadioButton id="apprRb" label="A"
click="radiobutton1_changeHandler(event)"
groupName="approvaRifiutaGroup"
selected="{data['flag']==ApprovazioneStraordinariView.APPROVA_FLAG}">
</s:RadioButton>
<s:RadioButton id="rifRb" label="R"
click="radiobutton1_changeHandler(event)"
groupName="approvaRifiutaGroup"
selected="{data['flag']==ApprovazioneStraordinariView.RIFIUTA_FLAG}">
</s:RadioButton>
<fx:Declarations>
<s:RadioButtonGroup id="approvaRifiutaGroup">
</s:RadioButtonGroup>
</fx:Declarations>
</mx:HBox>
</fx:Component>
</mx:itemRenderer>
Related
I am very new to flex. I have successfully added a dropDownList in my dataGrid table.The dropdownList works fine. Its just that since I am doing this for the user. I want to be able to see the dropDowList component/Icon itself in the dataGrid table, instead of me clicking the cell and then the dropDownList appears for me to select. Is it possible for me to achieve this?? Must I use flex skin or something ? Pls guide me on how can I can achieve this and pls if possible give me an example.
Thanks
Rekha
This is the code I have right now:
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import spark.events.IndexChangeEvent;
import mx.controls.Alert;
[Bindable]
private var myDP:ArrayCollection = new ArrayCollection([
{label1:"Order #2314", quant:3, color:'red'},
{label1:"Order #2315", quant:3, color:'red'}
]);
]]>
</fx:Script>
<s:DataGrid id="myDG" x="29" y="33" width="393" height="151" dataProvider="{myDP}"
editable="true" variableRowHeight="true">
<s:columns>
<s:ArrayList>
<s:GridColumn dataField="label1" headerText="Order #" editable="false"/>
<s:GridColumn dataField="quant" headerText="Qty" editable="true"/>
<s:GridColumn dataField="color" headerText="Color" editable="true">
<s:itemEditor>
<fx:Component>
<s:GridItemEditor>
<fx:Script>
<![CDATA[
import mx.core.FlexGlobals;
import mx.events.FlexEvent;
import spark.events.IndexChangeEvent;
override public function set value(newValue:Object):void {
cb.selectedItem = newValue;
}
override public function get value():Object {
return cb.selectedItem.toString();
}
override public function setFocus():void {
cb.setFocus();
}
override public function save():Boolean
{
data[column.dataField] = value;
return true;
}
]]>
</fx:Script>
<s:DropDownList id="cb" requireSelection="true" skinClass="MySkins.mytestddbSkin">
<s:dataProvider>
<s:ArrayCollection>
<fx:String>red</fx:String>
<fx:String>blue</fx:String>
<fx:String>green</fx:String>
</s:ArrayCollection>
</s:dataProvider>
</s:DropDownList>
</s:GridItemEditor>
</fx:Component>
</s:itemEditor>
</s:GridColumn>
</s:ArrayList>
</s:columns >
</s:DataGrid>
You can use an ItemRenderer instead of the ItemEditor. In this case you should set rendererIsEditable property of the GridColumn to true.
Then you can use the change event of the DropDownList, to register the change in your data provider.
I have added the color column twice to let you see, that the data is actually edited after the selection.
<?xml version="1.0" encoding="utf-8"?>
<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;
[Bindable]private var myDP:ArrayCollection = new ArrayCollection([
{label1:"Order #2314", quant:3, color:'red'},
{label1:"Order #2315", quant:3, color:'red'}
]);
]]>
</fx:Script>
<s:DataGrid id="myDG" x="29" y="33" height="151" dataProvider="{myDP}"
editable="true" variableRowHeight="true">
<s:columns>
<s:ArrayList>
<s:GridColumn dataField="label1" headerText="Order #" editable="false"/>
<s:GridColumn dataField="quant" headerText="Qty" editable="true"/>
<s:GridColumn dataField="color" headerText="Color" editable="true" width="120"/>
<s:GridColumn dataField="color" headerText="Color" editable="true" rendererIsEditable="true" width="180">
<s:itemRenderer>
<fx:Component>
<s:GridItemRenderer>
<fx:Script>
<![CDATA[
import spark.events.IndexChangeEvent;
protected function onCbChange(event:IndexChangeEvent):void
{
var value:String = (event.currentTarget as DropDownList).selectedItem;
data[column.dataField] = value;
}
]]>
</fx:Script>
<s:DropDownList id="cb" requireSelection="true" width="100%" change="onCbChange(event)">
<s:dataProvider>
<s:ArrayCollection>
<fx:String>red</fx:String>
<fx:String>blue</fx:String>
<fx:String>green</fx:String>
</s:ArrayCollection>
</s:dataProvider>
</s:DropDownList>
</s:GridItemRenderer>
</fx:Component>
</s:itemRenderer>
</s:GridColumn>
</s:ArrayList>
</s:columns >
</s:DataGrid>
</s:Application>
I have a spark datagrid with a custom itemrenderer which contains two buttons. I would like to allow the user to access those two buttons when tabbing through the controls in my page, is that possible?
I have put together a simple example application illustrating what I have attempted so far (just try tabbing through the buttons to see what i mean). Do i have to use a GridItemEditor?
Thanks in advance
Gav
<?xml version="1.0" encoding="utf-8"?>
<!-- dpcontrols\sparkdpcontrols\SparkDGStyledIR.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="450" height="450">
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.Alert;
// Data includes URL to album cover.
[Bindable]
private var initDG:ArrayCollection = new ArrayCollection([
{Artist:'Pavement', Album:'Slanted and Enchanted',
Price:11.99, Cover:'../assets/slanted.jpg', tabIndex:2},
{Artist:'Pavement', Album:'Slanted and Enchanted',
Price:11.99, Cover:'../assets/slanted.jpg', tabIndex:3},
{Artist:'Pavement', Album:'Slanted and Enchanted',
Price:11.99, Cover:'../assets/slanted.jpg', tabIndex:4},
{Artist:'Pavement', Album:'Brighten the Corners',
Price:11.99, Cover:'../assets/brighten.jpg', tabIndex:5}
]);
]]>
</fx:Script>
<s:layout>
<s:VerticalLayout />
</s:layout>
<s:DataGrid id="myGrid"
hasFocusableChildren="true" tabEnabled="true" tabChildren="true" focusEnabled="true" tabFocusEnabled="true"
dataProvider="{initDG}" selectionMode="singleCell" tabIndex="1"
variableRowHeight="true">
<s:columns>
<s:ArrayList>
<s:GridColumn dataField="Artist" rendererIsEditable="true">
<s:itemRenderer>
<fx:Component>
<s:GridItemRenderer hasFocusableChildren="true" tabEnabled="true" tabChildren="true" focusEnabled="true" tabFocusEnabled="true"
selectAll="meBtn.setFocus()">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
]]>
</fx:Script>
<s:Button id="meBtn" label="{this.data.tabIndex} Click me" click="Alert.show('clicked','info')" tabIndex="{this.data.tabIndex}"
tabEnabled="true" tabChildren="true" focusEnabled="true" tabFocusEnabled="true"/>
</s:GridItemRenderer>
</fx:Component>
</s:itemRenderer>
</s:GridColumn>
<s:GridColumn dataField="Album"/>
<s:GridColumn dataField="Price"/>
</s:ArrayList>
</s:columns>
</s:DataGrid>
<s:Button label="Some other button" tabIndex="100" click="Alert.show('this button below the grid is tab enabled fine','note')" />
</s:Application>
datagrid
editable = true
On the columns of you buttons you set
rendererIsEditable="true"
non editable columns
editable = false
Tabbing should work with these settings when you use a custom GridItemRender
Here's the situation:
I have a populated datagrid and I want to move a form to be inline (same y position) with the datagrid's selectedItem. I cannot rely on a mouseClick event because the selected item may change with a keyboard event. The datagrid does not have an itemRenderer, just plain old dataField.
Anyone done this before?
Here's some stubbed out example code for all those interested based on Jacob's answer.
<?xml version="1.0" encoding="utf-8"?>
<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;
import mx.events.FlexEvent;
import mx.events.ListEvent;
import mx.formatters.DateFormatter;
[Bindable] public var ac_POitems:ArrayCollection = new ArrayCollection();
[Bindable] public var selectedY:int;
protected function dg_POitems_creationCompleteHandler(event:FlexEvent):void
{
//TODO
}
protected function submit_clickHandler(event:MouseEvent):void
{
//TODO
}
protected function format_sqlite_date(item:Object, col:DataGridColumn):String
{
var df:DateFormatter = new DateFormatter();
df.formatString = "MM/DD/YYYY";
var value:Object = item[col.dataField];
return df.format(value);
}
protected function dg_POitems_changeHandler(event:ListEvent):void
{
trace(event.itemRenderer.y);
selectedY = event.itemRenderer.y;
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<mx:VBox width="100%" height="100%" paddingBottom="5" paddingLeft="5" paddingRight="5" paddingTop="5">
<mx:DataGrid id="dg_POitems" dataProvider="{ac_POitems}" creationComplete="dg_POitems_creationCompleteHandler(event)"
editable="true" height="100%" change="dg_POitems_changeHandler(event)">
<mx:columns>
<mx:DataGridColumn headerText="Consumer" dataField="consumer" editable="false"/>
<mx:DataGridColumn headerText="Description" dataField="description" width="300" editable="false"/>
<mx:DataGridColumn headerText="Amount" dataField="item_cost" editable="false" width="55"/>
<mx:DataGridColumn headerText="Service Date" dataField="service_date" labelFunction="format_sqlite_date"/>
<mx:DataGridColumn headerText="Invoice Date" dataField="invoice_date" labelFunction="format_sqlite_date"/>
<mx:DataGridColumn headerText="Paid Date" dataField="payment_received" labelFunction="format_sqlite_date"/>
</mx:columns>
</mx:DataGrid>
</mx:VBox>
<mx:Form id="form_POItemDateEditor" label="{dg_POitems.selectedItem.consumer}" x="{dg_POitems.x + dg_POitems.width + 10}"
y="{selectedY + 10}" visible="{dg_POitems.selectedItem}" borderColor="#ffffff">
<s:Label text="edit {dg_POitems.selectedItem.consumer}" width="100%" textAlign="center" verticalAlign="middle" fontWeight="bold" textDecoration="underline"/>
<mx:FormItem label="Service Date">
<mx:DateField id="service_date"/>
</mx:FormItem>
<mx:FormItem label="Invoie Date">
<mx:DateField id="invoice_date"/>
</mx:FormItem>
<mx:FormItem label="Paid Date">
<mx:DateField id="payment_received"/>
</mx:FormItem>
<mx:FormItem>
<s:Button id="submit" label="Submit" click="submit_clickHandler(event)"/>
</mx:FormItem>
</mx:Form>
</s:Application>
This should help you get started:
<fx:Script>
<![CDATA[
import mx.events.ListEvent;
protected function datagrid1_changeHandler(event:ListEvent):void
{
trace(event.itemRenderer.y);
}
]]>
</fx:Script>
<mx:DataGrid dataProvider="{steps}" change="datagrid1_changeHandler(event)" >
....
Edit Showing listener for spark:List valueCommit Event.
protected function valueCommitHandler(event:FlexEvent):void
{
trace(event.currentTarget.layout.getElementBounds(list.selectedIndex));
}
Have a look at DisplayObject's localToGlobal function. It will allow you to convert the ItemRenderer's 'y' position (that is with respect to the parent container, probably a List) to a global 'y' position (with respect to the Stage).
globalToLocal will do the opposite.
You'll have to do some additional calculations from here on, but those will depend on what your application display hierarchy looks like, so I can't be more specific than that.
You can find full code for exactly what you want to do right here http://flexdiary.blogspot.com/2009/11/flex-template-component.html
i am using below code to select/deselect all checkbox in datagrid
<mx:DataGridColumn id="testColumn" width="20" sortable="false">
<mx:headerRenderer>
<fx:Component>
<mx:Canvas>
<fx:Script>
<![CDATA[
protected function checkAll_clickHandle(event:MouseEvent):void
{
}
]]>
</fx:Script>
<s:CheckBox id="checkAll" horizontalCenter="0" selected="false" click="checkAll_clickHandler(event)"/>
</mx:Canvas>
</fx:Component>
</mx:headerRenderer>
<mx:itemRenderer>
<fx:Component>
<mx:Canvas width="100%" height="100%">
<fx:Script>
<![CDATA[
protected function check_clickHandler(event:MouseEvent):void
{
data.isSelected = (event.currentTarget as CheckBox).selected;
if(data.isSelected == false)
{
}
}
]]>
</fx:Script>
<s:CheckBox id="check" horizontalCenter="0" selected="{data.isSelected}" click="check_clickHandler(event)">
</s:CheckBox>
</mx:Canvas>
</fx:Component>
</mx:itemRenderer>
i want to unselct checkAll checkbox when i deselect any of row checkbox,
i am trying to access value of checkAll to check_clickHandler(), but i am not getting its value. how can i do this??
You can dispatch custom event with bubbling from your item renderer and handle it in your component. Then you can iterate your data provider or use some other algorithm to determine if there are unselected check boxes (data.isSelected) in data grid.
I added a checkbox in a DataGrid using ItemRenderer. I have pasted the code I am using below.
<mx:DataGrid id="dgEmployeeInfo" dataProvider="{resultArray}" x="131" y="95" editable="false">
<mx:columns>
<mx:DataGridColumn headerText="Select" rendererIsEditor="true" editorDataField="selected">
<mx:itemRenderer>
<fx:Component>
<mx:HBox>
<s:CheckBox id="testChk" click="testChk_clickHandler(event)" selected="{cbSelected}">
</s:CheckBox>
<fx:Script>
<![CDATA[
[Bindable]
public var cbSelected:Boolean;
protected function testChk_clickHandler(event:MouseEvent):void
{
cbSelected = testChk.selected;
}
]]>
</fx:Script>
</mx:HBox>
</fx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
<mx:DataGridColumn headerText="First Name" dataField="firstName"/>
<mx:DataGridColumn headerText="Last Name" dataField="lastName"/>
<mx:DataGridColumn headerText="City" dataField="city"/>
<mx:DataGridColumn headerText="Employee Code" dataField="empCode"/>
</mx:columns>
</mx:DataGrid>
I also have a button outside the DataGrid, and when this button is clicked, I want to delete all rows which have a checked CheckBox. Can someone tell me how to do this?
HI!
First of all, your code will not work properly, since not every DataGrid row has its own ItemRenderer instance. There are exactly n item renderer instances for a DataGrid having n VISIBLE rows. You can check this easily, if you create DataGrid, that can not fit all the data and then select some rows and scroll datagrid up/down. You'll see unexpected results.
One of solutions could be having additional field "selected" (or whatever you want to name it) in resultArray item properties. Then you can access this property through "data" object of ItemRenderer. Check the code below:
<?xml version="1.0" encoding="utf-8"?>
<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;
[Bindable]
private var resultArray:ArrayCollection = new ArrayCollection
([
{firstName:"1-1",lastName:"1-2",city:"1-3",empCode:"1-4"},
{firstName:"2-1",lastName:"2-2",city:"2-3",empCode:"2-4"},
{firstName:"3-1",lastName:"3-2",city:"3-3",empCode:"3-4"},
{firstName:"4-1",lastName:"4-2",city:"4-3",empCode:"4-4"},
{firstName:"5-1",lastName:"5-2",city:"5-3",empCode:"5-4"},
{firstName:"6-1",lastName:"6-2",city:"6-3",empCode:"6-4"},
{firstName:"7-1",lastName:"7-2",city:"7-3",empCode:"7-4"},
{firstName:"8-1",lastName:"8-2",city:"8-3",empCode:"8-4"},
{firstName:"9-1",lastName:"9-2",city:"9-3",empCode:"9-4"},
{firstName:"10-1",lastName:"10-2",city:"10-3",empCode:"10-4"},
]);
protected function button1_clickHandler(event:MouseEvent):void
{
for (var i:int=0; i< resultArray.length; i++)
{
if (resultArray[i].selected == true)
{
resultArray.removeItemAt(i);
}
}
dgEmployeeInfo.invalidateList();
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:VGroup>
<mx:DataGrid id="dgEmployeeInfo" dataProvider="{resultArray}" x="131" y="95" editable="false">
<mx:columns>
<mx:DataGridColumn headerText="Select" rendererIsEditor="true" editorDataField="selected">
<mx:itemRenderer>
<fx:Component>
<mx:HBox>
<s:CheckBox id="testChk" click="testChk_clickHandler(event)" selected="{data.selected}">
<fx:Script>
<![CDATA[
[Bindable]
public var cbSelected:Boolean;
protected function testChk_clickHandler(event:MouseEvent):void
{
data.selected = testChk.selected;
}
]]>
</fx:Script>
</s:CheckBox>
</mx:HBox>
</fx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
<mx:DataGridColumn headerText="First Name" dataField="firstName"/>
<mx:DataGridColumn headerText="Last Name" dataField="lastName"/>
<mx:DataGridColumn headerText="City" dataField="city"/>
<mx:DataGridColumn headerText="Employee Code" dataField="empCode"/>
</mx:columns>
</mx:DataGrid>
<mx:Button label="Delete Items" click="button1_clickHandler(event)"/>
</s:VGroup>
</s:Application>
I used ArrayCollection as dataProvider as it is much mor easier to add/remove items to Collection objects then with Arrays.
Regards.