[flexcoders] Using custom checkBox in datagrid

2007-10-31 Thread candysmate
I'm using a custom itemRenderer (centered checkBox), based upon Alex
Harui's  excellent blog in a dataGrid.

My dataGridColumn has:

mx:DataGridColumn

headerText=

dataField=select

width=30

itemRenderer=com.toro.classes.CenteredCheckBox
 
/mx:DataGridColumn   

the class is:

package com.toro.classes
{
import flash.display.DisplayObject;
import flash.text.TextField;
import mx.controls.CheckBox;

public class CenteredCheckBox extends CheckBox
{

public function CenteredCheckBox()
{
super();
}

/**
 *  center the contentHolder
 */
override protected function updateDisplayList(w:Number, h:Number):void
{
super.updateDisplayList(w, h);

var n:int = numChildren;
for (var i:int = 0; i  n; i++)
{
var c:DisplayObject = getChildAt(i);
if (!(c is TextField))
{
c.x = (w - c.width) / 2;
c.y = 0;
}
}
}

}

}

How can I get the boolean value held in array portion 'select' for the
dataProvider 'coloursArray' toggle when the checkbox is
selected/unselected please?



Re: [flexcoders] Using custom checkBox in datagrid

2007-10-31 Thread Scott Melby
Dispatch a custom event with bubbles set to true.  In the event include 
the checkbox that was checked so the code that catches it can get the 
selected state.  Then in the code that sets up your datagrid add an 
event listener to the grid itself as follows


this.myGrid.addEventListener(MyCustomEvent.MY_EVENT_TYPE, 
handleMyCustomEvent);


hth
Scott

Scott Melby
Founder, Fast Lane Software LLC
http://www.fastlanesw.com



candysmate wrote:


I'm using a custom itemRenderer (centered checkBox), based upon Alex
Harui's excellent blog in a dataGrid.

My dataGridColumn has:

mx:DataGridColumn
headerText=
dataField=select
width=30
itemRenderer=com.toro.classes.CenteredCheckBox
/mx:DataGridColumn

the class is:

package com.toro.classes
{
import flash.display.DisplayObject;
import flash.text.TextField;
import mx.controls.CheckBox;

public class CenteredCheckBox extends CheckBox
{

public function CenteredCheckBox()
{
super();
}

/**
* center the contentHolder
*/
override protected function updateDisplayList(w:Number, h:Number):void
{
super.updateDisplayList(w, h);

var n:int = numChildren;
for (var i:int = 0; i  n; i++)
{
var c:DisplayObject = getChildAt(i);
if (!(c is TextField))
{
c.x = (w - c.width) / 2;
c.y = 0;
}
}
}

}

}

How can I get the boolean value held in array portion 'select' for the
dataProvider 'coloursArray' toggle when the checkbox is
selected/unselected please?