3 Replies Latest reply on Sep 23, 2008 7:31 AM by ANewFlexUser

    Need ActionScript to set headerRenderer

    texas_stingray
      I an dynamicly adding columns to a datagrid and I also need to set the headerRenderer. I have a MXML component call DragHeader. When I set the dataGridColumn dgc.headerRenderer = DragHeader it is not being set. If I user the headerRenderer in a MXML componenet directly <mx:dataGridColumn .... headerRenderer="DragHeader" /> it work as designed. Can anyone help me with some action script to set it.

      Thanks
        • 1. Re: Need ActionScript to set headerRenderer
          EvolvedDSM Level 2
          Is DragHeader a component?
          • 2. Re: Need ActionScript to set headerRenderer
            Level 7

            "texas_stingray" <webforumsuser@macromedia.com> wrote in message
            news:gbal85$4es$1@forums.macromedia.com...
            >I an dynamicly adding columns to a datagrid and I also need to set the
            > headerRenderer. I have a MXML component call DragHeader. When I set the
            > dataGridColumn dgc.headerRenderer = DragHeader it is not being set. If I
            > user
            > the headerRenderer in a MXML componenet directly <mx:dataGridColumn ....
            > headerRenderer="DragHeader" /> it work as designed. Can anyone help me
            > with
            > some action script to set it.

            When you set renderers in ActionScript, you need to use a ClassFactory of
            the class instead of just the class. When you set a renderer in MXML, the
            wrapping just happens for you.

            HTH;

            Amy


            • 3. Re: Need ActionScript to set headerRenderer
              ANewFlexUser
              Here's an example from one of my projects, that uses a class factory to set the legendMarkerRenderer. Uou should be able to use a similar approach on your headerRenderer.

              import mx.charts.renderers.CircleItemRenderer;

              public var cf:ClassFactory
              cf = new ClassFactory(CircleItemRenderer);
              previousForecast.setStyle("legendMarkerRenderer", cf);