17
Feb
08

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.

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/02/17/setting-the-roll-over-color-and-selection-color-in-a-flex-datagrid-control/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <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:Array>

    <mx:DataGrid id="dataGrid"
            dataProvider="{arr}"
            rollOverColor="haloSilver"
            selectionColor="haloOrange"
            themeColor="black"
            width="300"
            rowCount="8">
        <mx:columns>
            <mx:DataGridColumn dataField="c1"
                    headerText="Column 1:" />
            <mx:DataGridColumn dataField="c2"
                    headerText="Column 2:" />
        </mx:columns>
    </mx:DataGrid>

</mx:Application>

View source is enabled in the following example.


1 Response to “Setting the roll over color and selection color in a Flex DataGrid control”


  1. 1 Priyanka Rane Feb 28th, 2008 at 3:00 am

    Thanks for this example…..It is simple which is useful for begineer like me ….

Leave a Reply

This blog is terrible at eating HTML tags. If you plan on posting code/XML, please escape your "<" characters as "&lt;" and your ">" characters as "&gt;".