3

How do you remove the header row from a Spark DataGrid? MX DataGrid had the attribute "showHeaders" but this doesn't seem to be present in the Spark DataGrid.

This seems like it should be a very easy task, so either I'm extremely dense or just missing something? Do I have to create a custom skin for my DataGrid and remove the header parts? That seems like overkill or is it the Flex / Spark way?

Thanks, Phil

zero323
  • 322,348
  • 103
  • 959
  • 935
Phil
  • 1,897
  • 4
  • 25
  • 48

2 Answers2

3

You should create a custom skin for DataGrid. You should just copy standard spark.skins.spark.DataGridSkin and remove there the following lines:

    <!--- @private -->
    <s:GridColumnHeaderGroup id="columnHeaderGroup"
        paddingLeft="1" paddingTop="1" paddingRight="1" minHeight="21" 
        columnSeparator="{headerColumnSeparator}"
        headerRenderer="{headerRenderer}"/>
Constantiner
  • 14,231
  • 4
  • 27
  • 34
  • Well that works and FlashBuilder made the process of Skin copying nice and easy. So is the use of skinning to modify the appearance of a Spark component the way that Adobe intended Spark components to be manipulated rather than having functionality to do it? I guess what I'm saying is why remove this functionality from Spark DataGrid when MX DataGrid had it? – Phil Sep 02 '11 at 11:21
  • MX DataGrig has limited abilities of customization out of the box and very complicated way for advanced customization. In addition to that MX way of customization can't be used in tools such as Flash Catalyst. And, finally, from the architectural point of view, old MX components was a kind of mix of MVC in the same bottle. New architecture separates representation from logic which adds more flexibility in process of creating custom components. Spark skins can be created in Flash Catalyst. Skins are readable and support declarative view states. And they are extremely customizable. – Constantiner Sep 02 '11 at 11:29
2

A lazy way is to set the skin's header height to 0:

<s:DataGrid id="dg"
  initialize="dg.columnHeaderGroup.height = 0"

or set the visible/includeInLayout properties:

<s:DataGrid id="dg"
  initialize="dg.columnHeaderGroup.visible =
              dg.columnHeaderGroup.includeInLayout = false"
Chris
  • 1,154
  • 10
  • 15