views:

14

answers:

1

This page describes how to override the drawHighlightIndicator/drawSelectionIndicators methods for the header of a DataGrid, but an AdvancedDataGrid does not have "headerClass" in mx_internal. It instead has an headerRenderer.

How can I remove those blasted highlights over an AdvancedDataGrid in Flex 3?

A: 

This really pisses me off about Flex 3 -- wish I could stop using it.

The graphics calls that draw that shit are in AdvancedDataGridBaseEx.as from lines 5468-5471:

var g:Graphics = s.graphics;
g.clear();
g.beginFill(getStyle("rollOverColor")); //all I really wanted was to decrease the alpha here :(
g.drawRect(0, 0, w, h - 0.5);
g.endFill();

To get rid of this you can do this in an class that extends AdvancedDataGrid:

package
{
    import flash.display.Sprite;
    import flash.events.MouseEvent;

    import mx.controls.AdvancedDataGrid;

    public class AdvancedDataGridMinusHighlights extends AdvancedDataGrid
    {
        public function AdvancedDataGridMinusHighlights()
        {
            super();
        }

        override protected function mouseOverHandler(event:MouseEvent):void
        {
            super.mouseOverHandler(event);

            var s:Sprite = Sprite(
                selectionLayer.getChildByName("headerSelection"));

            if(s) s.graphics.clear();

        }

        override protected function mouseDownHandler(event:MouseEvent):void
        {
            var s:Sprite = Sprite(
                selectionLayer.getChildByName("headerSelection"));

            if(s) s.graphics.clear();
        }

    }
}

Although that is an extremely inelegant solution since all it does is clear what has already been drawn. Because there's so much other crap in the mouse handlers in AdvancedDataGridBaseEx you won't easily be able to customize the appearance of the header.

A slightly more elegant (hack) solution is to copy the full source of AdvancedDataGridBaseEx into the mx.controls package (a hack I'm sure many of you are aware of and equally aware of the consequences).

Jonathan Dumaine