3 Replies Latest reply on Aug 11, 2008 7:29 AM by BrandG

    DataGrid highilght problem with ItemRendered Text

    BrandG
      I have a datagrid with some elements that are defined as using an itemrenderer:

      <mx:DataGrid id="dg" dataProvider="{dp}" >
      <mx:columns>
      <mx:DataGridColumn headerText="header" dataField="element" itemRenderer="dgRenderer" />

      Now, the item renderer just lists what text should be there:

      override public function set data(value:Object):void
      {
      this.text = "new text";
      }

      So, as far as it goes, this works fine (all app-specific stuff ripped out, but you get the idea). The text does show up in the datagrid correctly. However, when I mouse over the datagrid, normal (i.e. not-item-rendered) items get a dark background, and change their font to a gray color. However, item-rendered objects appear in black text, always.

      Does anyone know why that is, or how I can solve it?

      Thanks for any help you can provide.

      -Brand

        • 1. Re: DataGrid highilght problem with ItemRendered Text
          Level 7

          "BrandG" <webforumsuser@macromedia.com> wrote in message
          news:g7i3ne$8c4$1@forums.macromedia.com...
          >I have a datagrid with some elements that are defined as using an
          >itemrenderer:
          >
          > <mx:DataGrid id="dg" dataProvider="{dp}" >
          > <mx:columns>
          > <mx:DataGridColumn headerText="header" dataField="element"
          > itemRenderer="dgRenderer" />
          >
          > Now, the item renderer just lists what text should be there:
          >
          > override public function set data(value:Object):void
          > {
          > this.text = "new text";
          > }
          >
          > So, as far as it goes, this works fine (all app-specific stuff ripped out,
          > but
          > you get the idea). The text does show up in the datagrid correctly.
          > However,
          > when I mouse over the datagrid, normal (i.e. not-item-rendered) items get
          > a
          > dark background, and change their font to a gray color. However,
          > item-rendered
          > objects appear in black text, always.
          >
          > Does anyone know why that is, or how I can solve it?
          >
          > Thanks for any help you can provide.

          Here are some options:

          1) Just use a labelFunction
          2) Extend the default itemRenderer
          3) Look at the code for the default itemRenderer and see how it handles
          this

          HTH;

          Amy


          • 2. Re: DataGrid highilght problem with ItemRendered Text
            BrandG Level 1
            Thanks Amy. I'm working on extending the default ItemRenderer now. Must not have got it right, because now it's returning the wrong text, but with the right color, so that's something!

            I'll figure it out, and thanks again.

            -Brand
            • 3. Re: DataGrid highilght problem with ItemRendered Text
              BrandG Level 1
              Quick follow-up. In case anyone is wondering about that last part, the reason the text was wrong was because in the ItemRenderer object's "set" function, I was setting "this.text" (which worked fine when I accessed it through MXML). However, in this case, I needed to set the "super.listData.label" for it to show up correctly.