[flexcoders] Re: Using custom checkBox in datagrid

2007-10-31 Thread candysmate
--- In flexcoders@yahoogroups.com, Scott Melby [EMAIL PROTECTED] wrote:

 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
 

Many thanks Scott.



[flexcoders] Re: Using custom checkBox in datagrid

2007-10-31 Thread ben.clinkinbeard
You don't need a custom event as MouseEvent.CLICK already bubbles.
Simply listen for that event and then check if(event.target is
CenteredCheckBox).

HTH,
Ben


--- In flexcoders@yahoogroups.com, candysmate [EMAIL PROTECTED] 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?





[flexcoders] Re: Using custom checkBox in datagrid

2007-10-31 Thread candysmate
--- In flexcoders@yahoogroups.com, ben.clinkinbeard
[EMAIL PROTECTED] wrote:

 You don't need a custom event as MouseEvent.CLICK already bubbles.
 Simply listen for that event and then check if(event.target is
 CenteredCheckBox).
 
 HTH,
 Ben
 

Much cleaner. Many thanks for your input Ben.