Changing the default sort arrow skin on a Flex DataGrid control

The following example shows how you can change the sort arrow skin on a DataGrid control in Flex by setting the sortArrowSkin style.

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.

You can also set the sortArrowSkin style in an external .CSS file or <mx:Style /> block, as shown in the following snippet:

    DataGrid {
        sortArrowSkin: Embed("assets/thumb_down.png");

Or, you can set the sortArrowSkin style using ActionScript, using the following snippet:

        private var thumbDownIcon:Class;

        private function init():void {
            dataGrid.setStyle("sortArrowSkin", thumbDownIcon);

7 thoughts on “Changing the default sort arrow skin on a Flex DataGrid control

  1. Thanks for another great Flex tip. One question I have about the sort arrow is how do you get the sort arrow to appear without having to click on a column header? I have an app where I need the arrow to show after the data loads.

    1. @Kevin/A Visitor,

      Using the sortArrowSkin style. The sortArrowSkin skin is just flipped vertically depending on whether it is an ascending sort or descending sort.

      <mx:DataGrid id="dataGrid" ... sortArrowSkin="@Embed('assets/thumb_down.png')" />


  2. I know this blog is really old, but I have a correlating question. Is there any way to change the position of the sort arrow?? I’d like to have it appear just left/right of the column header text.

Comments are closed.