"accountBalance" is the name of the dataField. so you can do the following in your renderer
override public function set data(value:Object):void { var myListData:DataGridListData = DataGridListData(listData); var myDataField:String = myListData.dataField; trace (data[myDataField]); --- In flexcoders@yahoogroups.com, "barry.beattie" <[EMAIL PROTECTED]> wrote: > > > (background) > I'm looking at some code(*) on extending controls to add extra > formatting and validation. I need to have a dateField accept null > values, alert if text entry is not a date and format the picker date > to "DD/MM/YYYY" > - for an itemRenderer of a dataGrid > > (anyway...) > I'm really worried over something I've found (in many examples): a > hard-wired reference to a parent property: > > this.text = cf.format(value.accountBalance); // the "accountBalance" > > relates back to > > <mx:DataGridColumn width="80" textAlign="right" > headerText="Balance" > headerRenderer="HeaderRenderer" > dataField="accountBalance" > itemRenderer="AccountBalanceItemRenderer"/> > > in my mind this isn't as portable/re-usable as it could be, especially > since my custom dateField will be used in 3 places in the same dataGrid. > > can I ask how this can be written so it'll apply to anywhere it's > used? make it truly a re-usable control? (the "value.accountBalance" part) > > thanx > barry.b > > package { > > import mx.controls.Text; > import mx.formatters.CurrencyFormatter > > public class AccountBalanceItemRenderer extends Text > { > override public function set data(value:Object):void { > super.data = value; > > var cf:CurrencyFormatter = new CurrencyFormatter; > cf.currencySymbol = "$"; > cf.precision = 2; > > if(value!=null) { > if (Number(value.accountBalance) < 0) > { > this.setStyle("color","red"); > } else { > this.setStyle("color","black"); > } > > this.text = cf.format(value.accountBalance); > } > super.invalidateDisplayList(); > > } > } > } > > > (*) I'm not publicly showing the URL where I got this - that ain't > fair. the kind chap that wrote it has just presented a consise example > of what I mean. I've seen this sort of thing in lots of Flex code... > -- 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/