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
>
>
>
>
>
>
>
------------------------ Yahoo! Groups Sponsor --------------------~-->
Fair play? Video games influencing politics. Click and talk back!
http://us.click.yahoo.com/T8sf5C/tzNLAA/TtwFAA/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/