Tutorial :Flex DataGrid Remove Header MouseOver Highlighting


I want to remove the highlight that occurs when mouse over occurs on the headers of a DataGrid.


Maybe the following hack will help someone. I simply wanted to remove the rollover and selection from datagrid header (flex 3).

What I made:

1) Create a new subclass of DataGridHeader and override drawHeaderIndicator and drawSelectionIndicator

package  {   import flash.display.Sprite;     import mx.controls.dataGridClasses.DataGridHeader;   import mx.controls.listClasses.IListItemRenderer;     public class MyDataGridHeader extends DataGridHeader   {    public function MyDataGridHeader()    {     super();    }      override protected function drawHeaderIndicator(indicator:Sprite, x:Number, y:Number, width:Number, height:Number, color:uint, itemRenderer:IListItemRenderer):void    {      }      override protected function drawSelectionIndicator(indicator:Sprite, x:Number, y:Number, width:Number, height:Number, color:uint, itemRenderer:IListItemRenderer):void    {      }   }  }  

2) Create a new subclass of DataGrid - lets say MyDataGrid and in constructor do the following:

public function MyDataGrid()    {     super();     this.mx_internal::headerClass = MyDataGridHeader;     ....    }  

This will force DataGrid to use your DataGridHeader.


If you don't need sorting on that column, just set sortable to false, and it won't get highlighted on mouse over.


This might help you:


Basically what I've found is that you can't just change it. It requires extending the header class and a whole bunch of other stuff I don't know how to do yet.


dont forget to add this import at MyDataGrid file

import mx.core.mx_internal;

works perfectly thanks.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »