Tim as always the credit goes to you. i'll have a look at trying it with a custom event as you described.
regards bod --- In flexcoders@yahoogroups.com, "Tim Hoff" <[EMAIL PROTECTED]> wrote: > > Absolutely, > > That sample, at the time, was designed to illustrate itemRenderers. > The better way to do it, would be to dispatch custom events. Glad > that it got you moving in the right direction; to come up with a > better solution. > > Cool, > -TH > > --- In flexcoders@yahoogroups.com, "bhaq1972" <mbhaque@> wrote: > > > > I found a way to make it generic. all i did was implement > > IDropInListItemRenderer (code below). > > > > so now u can have > > > > <mx:DataGridColumn dataField="any" itemRenderer="myCheckBox"/> > > <mx:DataGridColumn dataField="name" itemRenderer="myCheckBox"/> > > <mx:DataGridColumn dataField="you" itemRenderer="myCheckBox"/> > > <mx:DataGridColumn dataField="like" itemRenderer="myCheckBox"/> > > <mx:DataGridColumn dataField="focusIn" itemRenderer="myCheckBox"/> > > > > you can replace the following code > > if(data.focusIn) > > checkbox1.selected = data.focusIn; > > if(data.any) > > checkbox1.selected = data.any; > > etc > > > > instead u can do > > > > var myListData:DataGridListData = DataGridListData(listData); > > var myDataField:String = myListData.dataField; > > > > checkbox1.selected = data[myDataField]; > > > > > > MyCheckBox > > ---------- > > <mx:HBox > implements="mx.controls.listClasses.IDropInListItemRenderer" > > preinitialize ="initTA();" horizontalAlign="center"> > > > > <mx:Script> > > // Internal variable for the property value. > > private var _listData:BaseListData; > > > > // Make the listData property bindable. > > [Bindable("dataChange")] > > > > // Define the getter method. > > public function get listData():BaseListData > > { > > return _listData; > > } > > > > // Define the setter method, > > public function set listData(value:BaseListData):void > > { > > _listData = value; > > } > > > > public function initTA():void > > { > > this.addEventListener("dataChange", handleDataChanged); > > } > > > > public function handleDataChanged(event:Event):void > > { > > // Cast listData to DataGridListData. > > var myListData:DataGridListData = DataGridListData > (listData); > > var myDataField:String = myListData.dataField; > > > > checkbox1.selected = data[myDataField]; > > } > > </mx:Script> > > > > <mx:CheckBox id="checkBox1" /> > > > > </mx:HBox> > > > > > > --- In flexcoders@yahoogroups.com, "bhaq1972" <mbhaque@> wrote: > > > > > > thanks for the input guys. But i have one issue. > > > > > > In your example Tim, your checkbox item renderer is binding onto > > > the 'followUp' property of the dataProvider. > > > eg > > > > > > <mx:CheckBox id="cbFollowUp" selected="{data.followUp}"/> > > > > > > 'followUp' is the name of your dgcolumn dataField. So wouldn't > it > > be > > > better and more generic if you could do > > > > > > <mx:CheckBox id="cbFollowUp" selected="{data.dataField}"/> > > > > > > i'm applying this renderer across many datagrids and the > dataField > > > name isn't the same. > > > > > > regards > > > > > > Bod > > > > > > > > > --- In flexcoders@yahoogroups.com, "Tim Hoff" <TimHoff@> wrote: > > > > > > > > > > > > In addition to Ben's example for the label, here's a sample > for > > the > > > > selected value: > > > > > > > > http://www.cflex.net/showfiledetails.cfm? > > > ChannelID=1&Object=File&objectI\ > > > > D=443 > > > > <http://www.cflex.net/showfiledetails.cfm? > > > ChannelID=1&Object=File&object\ > > > > ID=443> > > > > > > > > -TH > > > > > > > > --- In flexcoders@yahoogroups.com, "ben.clinkinbeard" > > > > <ben.clinkinbeard@> wrote: > > > > > > > > > > <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" > > > > > horizontalAlign="center" > > > > > > > > > > <mx:CheckBox id="checkbox1" label="data.myLabelField" /> > > > > > > > > > > </mx:HBox> > > > > > > > > > > --- In flexcoders@yahoogroups.com, "bhaq1972" mbhaque@ wrote: > > > > > > > > > > > > i have a checkbox renderer like this. > > > > > > > > > > > > <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" > > > > > > horizontalAlign="center" > > > > > > > > > > > > <mx:CheckBox id="checkbox1"/> > > > > > > > > > > > > </mx:HBox> > > > > > > > > > > > > How do i get access to the DataGridColumn its being > > referenced > > > in ie > > > > > > > > > > > > <mx:DataGridColumn dataField="col1" > > > itemRenderer="myCheckBox" /> > > > > > > > > > > > > i want to access the dataField. > > > > > > > > > > > > > > > > > > regards > > > > > > Bod > > > > > > > > > > > > > > > > > > > > > -- 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/