I would just subclass Label, override the getter/setter for dataObject, and then when dataObject is set use your formatter to update the text.

 

Sorry, don’t have example code right now.

 

I’m also going to file a bug to make sure that our dataObject and related getter/setters are always bindable.

 

Matt

 


From: [email protected] [mailto:[email protected]] On Behalf Of Greg Johnson
Sent: Monday, October 24, 2005 7:49 AM
To: [email protected]
Subject: [flexcoders] Re: FLEX2: Date Cell Renderer

 

Think i replyed to the wrong addy since it hasn't shown up in the
list. 

Is there some code somewhere I can look at that specificaly is
redering the date.  I have messed around and can get a datefield box
to show, but I don't need to have it edit, I just need to display the
date mm/dd/yyyy.  I have also written my own mxml and still nogo.

--- In [email protected], Jim Laing <[EMAIL PROTECTED]> wrote:
>
> In Flex 2, the cell render API is totally different. For one thing,
> setValue() is no longer used. For another thing, a cell render is
> passed a "dataObject" (or something like that) value, which contains
> the data to be rendered. All of the examples I've seen thus far are
> straight MXML, and most are rendered inline, so you might want to
try
> heading in that direction.
>
> Jim
>
> On 10/21/05, Greg Johnson <[EMAIL PROTECTED]> wrote:
> > Ok, for flex 1.5 I had downloaded a nice AS file that would render
> > dates in cells for me.  However dispite me updateing it to work in
> > Flex 2 it doesn't.  Any ideas what I missed?
> >
> >
> > /*
> >  * DateFormatCellRenderer is a simple Label-based cell renderer
that
> > displays
> >  * its item content in a known date format.
> >  */
> > package {
> > import mx.formatters.DateFormatter;
> > import mx.controls.Label;
> > class DateFormatCellRenderer extends Label
> > {
> >         var getDataLabel:Function;
> >         static var dateFmt:DateFormatter;
> >
> >         private function init() : Void
> >         {
> >                 // instantiate the 1 and only date formatter (more
> > efficient than
> >                 // have a date formatter for every instance of the
> > cell renderer).
> >                 if( dateFmt == null ) {
> >                         dateFmt = new DateFormatter();
> >                         dateFmt.formatString = "MM/DD/YYYY";
> >                 }
> >                 super.initialize();
> >         }
> >
> >         private function setValue(str:String, item:Object,
> > sel:Boolean):Void
> >         {
> >                 if( item != null ) {
> >                         // format the date value in the cell
> >                         this.text = dateFmt.format(item
[getDataLabel
> > ()]);
> >                 }
> >                 else {
> >                         this.text = "";
> >                 }
> >         }
> >
> >         private function size() : Void
> >         {
> >                 this.setActualSize(explicitWidth,explicitHeight);
> >         }
> > }
> > }
> >
> > btw the size function change is a complete guess on my part.
> >
> >
> >
> >
> >
> >
> > --
> > 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
> >
> >
> >
> >
> >
> >
> >
>







--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




Reply via email to