2 Replies Latest reply on Feb 10, 2009 5:09 PM by

    Formatting text in datagrid cells

      Hi,
      I have a datagrid that displays dates in some of its columns. I want to be able to format the dates in an application specific format that is different from the standard toString that is displayed if I just use the date field as the source for the date columns. I also want sorting on that column to work based on the date and not on a string sort of the formatted date.

      I have written an item renderer that extends label and I am able to render the date in the format that I want. However, I can not figure out how to enable the label to forward mouse events to the datagrid so that clicking on that cell will cause the grid to select the row that the date appears on. Also - hovering over the cell doesn't hilight the row either.

      I have attached source code for the date renderer that I have come up with so far that formats correctly but does not forward events to the datagrid.

      Is this on the right track? Or is there a better approach altogether?

      Thanks!

      Ryan
        • 1. Re: Formatting text in datagrid cells
          Level 7

          "mountaindrum" <webforumsuser@macromedia.com> wrote in message
          news:gm9lvn$stg$1@forums.macromedia.com...
          > Hi,
          > I have a datagrid that displays dates in some of its columns. I want to be
          > able to format the dates in an application specific format that is
          > different
          > from the standard toString that is displayed if I just use the date field
          > as
          > the source for the date columns. I also want sorting on that column to
          > work
          > based on the date and not on a string sort of the formatted date.
          >
          > I have written an item renderer that extends label and I am able to render
          > the
          > date in the format that I want. However, I can not figure out how to
          > enable the
          > label to forward mouse events to the datagrid so that clicking on that
          > cell
          > will cause the grid to select the row that the date appears on. Also -
          > hovering
          > over the cell doesn't hilight the row either.
          >
          > I have attached source code for the date renderer that I have come up with
          > so
          > far that formats correctly but does not forward events to the datagrid.
          >
          > Is this on the right track? Or is there a better approach altogether?

          Look at labelFunction.

          HTH;

          Amy


          • 2. Re: Formatting text in datagrid cells
            Thanks Amy. That was what I was looking for.