Setting the roll over color and selection color in a Flex DataGrid control

The following example shows how you can set the roll over color and selection color in a DataGrid control in Flex by setting the rollOverColor and selectionColor styles.

Full code after the jump.


<?xml version="1.0" encoding="utf-8"?>
<!-- -->
<mx:Application xmlns:mx=""

    <mx:Array id="arr">
        <mx:Object c1="Item 1A" c2="Item 1B" />
        <mx:Object c1="Item 2A" c2="Item 2B" />
        <mx:Object c1="Item 3A" c2="Item 3B" />
        <mx:Object c1="Item 4A" c2="Item 4B" />
        <mx:Object c1="Item 5A" c2="Item 5B" />
        <mx:Object c1="Item 6A" c2="Item 6B" />
        <mx:Object c1="Item 7A" c2="Item 7B" />
        <mx:Object c1="Item 8A" c2="Item 8B" />
        <mx:Object c1="Item 9A" c2="Item 9B" />

    <mx:DataGrid id="dataGrid"
            <mx:DataGridColumn dataField="c1"
                    headerText="Column 1:" />
            <mx:DataGridColumn dataField="c2"
                    headerText="Column 2:" />


View source is enabled in the following example.

6 thoughts on “Setting the roll over color and selection color in a Flex DataGrid control

  1. tnx for the good work…
    i have a question..
    how do i cancel the selection color but keep the event..?
    i’m using custom styles for the rollover but i cant seem to get rid of the selection color..

    thanks in advanced :)

  2. What if I want to disable the header rollover? Is that possible while still maintaining sort functionality?

  3. I set “color” of each cell in datagrid based on condition. ie based on a condition the text in the cell is either red or blue.
    But for a highlighted row (either on selection or rollover) , the color of text is lost.
    I have noticed that this is the case when selectionMode=”singleRow”. When selectionMode=”singleCell”, and the cell is highlighted, the color of text is not lost. Please let me know if someone has solution to this problem.

    Thanks in advance

Comments are closed.