Setting explicit columns on a Spark DataGrid control in Flex Hero

The following example shows how you can set explicit columns on a Spark DataGrid control in Flex Hero by setting the columns property to an IList implementation (for example ArrayCollection or ArrayList).

The following example(s) require Flash Player 10 and the beta Adobe Flex Hero SDK. To download the Adobe Flash Builder 4 trial, see To download the latest nightly build of the Flex Hero SDK, see

<?xml version="1.0" encoding="utf-8"?>
<!-- -->
<s:Application name="Spark_DataGrid_columns_test"
    <s:DataGrid id="dg" horizontalCenter="0" verticalCenter="0">
                <s:GridColumn dataField="fontName" />
            <s:ArrayList source="{Font.enumerateFonts(true).sortOn('fontName')}" />

This entry is based on a beta version of the Flex Hero SDK and therefore is very likely to change as development of the Flex SDK continues. The API can (and will) change causing examples to possibly not compile in newer versions of the Flex Hero SDK.

2 thoughts on “Setting explicit columns on a Spark DataGrid control in Flex Hero

  1. Hi

    I’ve been testing the Spark datagrid for a while and i cant figure out one thing:
    How can i get the x position of the columns?
    I’ve tried to do it this way: dataGrid.columns.getItemAt(2).width
    This gives back NaN, unless i specify the size of the column, or resize the column.

    In the debugger, i saw that these properties are in
    dataGrid.grid.gridLayout.gridDimensions._columnwidths – but this is a private property.
    Anyone know a way to get these values?

  2. Flashbuilder 4.5.1:
    Using an arrayList as dataProvider will cause that you cannot use the sortableColumns functionality of a spark datagrid. With an arrayCollection as dataProvider sortableColumns is working.

Comments are closed.