Nice and simple. Props. -TH
--- In [email protected], "Jeremy Lu" <[EMAIL PROTECTED]> wrote: > > this is the snippet from my code library: > > package > { > import mx.containers.HBox; > import mx.controls.CheckBox; > > public class CheckBox2 extends HBox{ > > public function CheckBox2(){ > this.setStyle("horizontalAlign", "center"); > } > > var c:mx.controls.CheckBox; > > override protected function createChildren():void{ > c = new CheckBox(); > this.addChild( c ); > } > > override public function set data(item:Object):void { > > super.data = item; > > if( item!=null ){ > c.selected = (item.Sent == 1)?true:false ; > } > > } > > > } > } > > === mxml =============== > > <?xml version="1.0" encoding="utf-8"?> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> > > <mx:Script> > <![CDATA[ > > [Bindable] > public var myDP:Array = [ > {label1:"Order #2314", contact:"John Doe", quant:3, solddate:new > Date(2005, 0, 1), Sent:1}, > {label1:"Order #2315", contact:"Jane Doe", quant:3, solddate:new > Date(2005, 0, 5), Sent:0}]; > ]]> > </mx:Script> > > <mx:DataGrid id="myDG" dataProvider="{myDP}" variableRowHeight="true" > width="500" height="250" editable="true"> > <mx:columns> > <mx:DataGridColumn dataField="label1" headerText="Order #" > editable="false"/> > <mx:DataGridColumn dataField="quant" > headerText="Quantity" > itemEditor="mx.controls.NumericStepper" > editorDataField="value"/> > <mx:DataGridColumn dataField="solddate" > headerText="Date" itemRenderer=" mx.controls.DateField" > rendererIsEditor="true" editorDataField="selectedDate"/> > > <mx:DataGridColumn itemRenderer="CheckBox2" dataField="Sent" > rendererIsEditor="true" editorDataField="data" /> > > > </mx:columns> > </mx:DataGrid> > </mx:Application> > > ========================= > > things to note: > > 1. Using HBox (or any containers) inside item renderer is very *expensive* > (said Joan Tan from Adobe), which might be the cause for sluggish scrolling > of Datagrid. > > 2. Most of the time my item renderer are a composition of multiple UI > components, so I have to use Box or other kind of Containers. > > 3. Anatole's approach (using DataGridListData (listData).dataField ) is more > abstractive so that the renderer is generic enough for easy reuse later, if > you just need one single chechbox in there, that's the best way to go > (IMHO). > ------------------------ Yahoo! Groups Sponsor --------------------~--> Check out the new improvements in Yahoo! Groups email. http://us.click.yahoo.com/6pRQfA/fOaOAA/yQLSAA/nhFolB/TM --------------------------------------------------------------------~-> -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/

