Removing the header separator on the DataGrid control in Flex
The following example shows how you can remove the header separator skin on the Flex DataGrid control by setting the headerSeparatorSkin style.
Full code after the jump.
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2009/03/20/removing-the-header-separator-on-the-datagrid-control-in-flex/ -->
<mx:Application name="DataGrid_headerSeparatorSkin_test"
xmlns:mx="http://www.adobe.com/2006/mxml"
backgroundColor="white">
<mx:DataGrid id="dataGrid"
headerSeparatorSkin="mx.skins.ProgrammaticSkin">
<mx:dataProvider>
<mx:ArrayCollection>
<mx:Object c1="1. One" c2="1. Two" c3="1. Three" />
<mx:Object c1="2. One" c2="2. Two" c3="2. Three" />
<mx:Object c1="3. One" c2="3. Two" c3="3. Three" />
<mx:Object c1="4. One" c2="4. Two" c3="4. Three" />
<mx:Object c1="5. One" c2="5. Two" c3="5. Three" />
<mx:Object c1="6. One" c2="6. Two" c3="6. Three" />
</mx:ArrayCollection>
</mx:dataProvider>
</mx:DataGrid>
</mx:Application>
You can also set the headerSeparatorSkin style in an external .CSS file or <Style/> block, as seen in the following example:
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2009/03/20/removing-the-header-separator-on-the-datagrid-control-in-flex/ -->
<mx:Application name="DataGrid_headerSeparatorSkin_test"
xmlns:mx="http://www.adobe.com/2006/mxml"
backgroundColor="white">
<mx:Style>
DataGrid {
headerSeparatorSkin: ClassReference("mx.skins.ProgrammaticSkin");
}
</mx:Style>
<mx:DataGrid id="dataGrid">
<mx:dataProvider>
<mx:ArrayCollection>
<mx:Object c1="1. One" c2="1. Two" c3="1. Three" />
<mx:Object c1="2. One" c2="2. Two" c3="2. Three" />
<mx:Object c1="3. One" c2="3. Two" c3="3. Three" />
<mx:Object c1="4. One" c2="4. Two" c3="4. Three" />
<mx:Object c1="5. One" c2="5. Two" c3="5. Three" />
<mx:Object c1="6. One" c2="6. Two" c3="6. Three" />
</mx:ArrayCollection>
</mx:dataProvider>
</mx:DataGrid>
</mx:Application>
Or, you can set the headerSeparatorSkin style using ActionScript, as seen in the following example:
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2009/03/20/removing-the-header-separator-on-the-datagrid-control-in-flex/ -->
<mx:Application name="DataGrid_headerSeparatorSkin_test"
xmlns:mx="http://www.adobe.com/2006/mxml"
backgroundColor="white">
<mx:Script>
<![CDATA[
import mx.skins.ProgrammaticSkin;
private function btn_click(evt:MouseEvent):void {
dataGrid.setStyle("headerSeparatorSkin", ProgrammaticSkin);
}
]]>
</mx:Script>
<mx:Button id="btn"
label="Set header separator skin"
click="btn_click(event);" />
<mx:DataGrid id="dataGrid">
<mx:dataProvider>
<mx:ArrayCollection>
<mx:Object c1="1. One" c2="1. Two" c3="1. Three" />
<mx:Object c1="2. One" c2="2. Two" c3="2. Three" />
<mx:Object c1="3. One" c2="3. Two" c3="3. Three" />
<mx:Object c1="4. One" c2="4. Two" c3="4. Three" />
<mx:Object c1="5. One" c2="5. Two" c3="5. Three" />
<mx:Object c1="6. One" c2="6. Two" c3="6. Three" />
</mx:ArrayCollection>
</mx:dataProvider>
</mx:DataGrid>
</mx:Application>
Peter deHaan
Peter deHaan currently works for Adobe on the Flex SDK QA team. While not working on Flex, Flash, and ColdFusion applications, Peter enjoys making up bios and writing in 3rd person. Peter's rarely updated blog can be found at blogs.adobe.com/pdehaan/, actionscriptexamples.com, airexamples.com, and coldfusionexamples.com.
-
Add Widgets (Content Sidebar)
This is your Content Sidebar. Edit this content that appears here in the widgets panel by adding or removing widgets in the Content Sidebar area.
7 Responses to Removing the header separator on the DataGrid control in Flex
-
Categories
- Accordion
- AccordionHeader
- ActionScript
- AddChild
- AdvancedDataGrid
- Alert
- alpha
- Animate
- AnimateProperties
- Application
- Application (Spark)
- ArrayCollection
- BarChart
- baseColor
- beta
- beta1
- beta2
- Bitmap
- Bitmap/BitmapData
- BitmapData
- BitmapFill
- BitmapFill (Spark)
- BitmapGraphic
- BitmapImage
- BitmapImage (Spark)
- BitmapImageResizeMode
- Border (Spark)
- BorderContainer (Spark)
- Box
- BuildInfo
- Button
- Button (Spark)
- ButtonBar
- ButtonBar (Spark)
- ByteArray
- Camera
- Charting
- CheckBox
- CheckBox (Spark)
- ClassFactory
- CollectionEvent
- Color
- ColorPicker
- ColorUtil
- ComboBox
- ComboBoxArrowSkin
- Compiler
- Component
- Component (Spark)
- Configuration
- Container
- ContextMenu
- ContextMenuEvent
- ContextMenuItem
- CSSCondition
- CSSSelector
- CSSStyleDeclaration
- CurrencyFormatter
- CursorManager
- Data Binding
- DataGrid
- DataGrid (Spark)
- DataGridColumn
- Date
- DateBase
- DateChooser
- DateField
- DateFormatter
- Debugging
- DefaultComplexItemRenderer
- DefaultTileListEffect
- DropDownList
- DropDownList (Spark)
- DropDownListButtonSkin
- DropDownListSkin
- DropShadowFilter
- E4X
- Effects
- Ellipse
- EmailValidator
- Embed
- Event
- Fade
- FileFilter
- FileReference
- fill
- Filters
- Flash
- Flash Integration
- FlashVars
- Flex 3 SDK
- Flex Builder
- Flex Builder 3
- Flex SDK
- Flex4
- FLVPlayback
- FocusManager
- FontLookup
- Fonts
- Form
- Form (Spark)
- FormHeading (Spark)
- FormItem
- FormItem (Spark)
- Forms
- FTETextField (Spark)
- FullScreen
- FullScreenEvent
- FxAnimateColor
- FxButtonBar
- FxCheckBox
- FXG
- FxHScrollBar
- FxHSlider
- FxList
- FxNumericStepper
- FxRadioButton
- FxRotate3D
- FxScroller
- FxTextArea
- FxTextInput
- FxToggleButton
- FxVScrollBar
- FxVSlider
- getStyleDeclaration()
- GradientEntry
- Graphic (Spark)
- HBox
- HDividedBox
- HGroup (Spark)
- HorizontalLayout
- HorizontalList
- HSBColor (Spark)
- HScrollBar (Spark)
- HSlider
- HSlider (Spark)
- HTML template
- ID3Info
- Image
- Image (Spark)
- ImageSnapshot
- itemRenderer
- JointStyle
- Label
- Label (Spark)
- Legend
- LegendItem
- LigatureLevel
- Line
- LinearGradientStroke
- LineScaleMode
- LinkBar
- LinkButton
- List
- List (Spark)
- Menu
- MenuBar
- Metadata
- MetadataEvent
- Model
- Mouse
- MouseCursor
- MouseEvent
- Move
- Namespace
- NavigatorContent (Spark)
- needsSWF
- NetConnection
- NetStream
- Nightly Builds
- NumberBaseRoundType
- NumberFormatter
- NumberValidator
- NumericCompare
- NumericStepper
- NumericStepper (Spark)
- ObjectProxy
- ObjectUtil
- paddingLeft
- paddingRight
- Panel
- Panel (Spark)
- Parallel
- Path
- PieChart
- PieSeries
- PieSeriesItem
- PopUpAnchor (Spark)
- PopUpButton
- PopUpManager
- ProgrammaticSkin
- ProgressBar
- PropertyChangeEvent
- QName
- RadialGradient
- RadioButton
- RadioButton (Spark)
- RadioButtonGroup
- RadioButtonGroup (Spark)
- Rect
- RegExp
- Regular Expressions
- Repeater
- RichEditableText
- RichText
- RichText (Spark)
- RichTextEditor
- Rotate
- Rotate3D (Spark)
- Scroller (Spark)
- Sequence
- setStyle()
- SimpleText
- SimpleText (Spark)
- skinClass
- Slider
- SliderEvent
- SolidColor
- SolidColorStroke
- Sort
- SortField
- Sound
- SoundEffect
- Spinner (Spark)
- SpriteVisualElement (Spark)
- StageDisplayState
- States
- StringUtil
- StringValidator
- StyleManager
- Styles
- SWFLoader
- SWFObject
- System
- SystemManager
- TabBar
- TabBar (Spark)
- TabNavigator
- TabStopFormat
- Text
- Text Layout Framework (TLF)
- TextArea
- TextArea (Spark)
- TextBox
- TextConverter
- TextEvent
- TextFlow
- TextFlowUtil
- TextFormat
- TextGraphic
- TextInput
- TextInput (Spark)
- TextLayoutFormat
- TextView
- Themes
- TileLayout
- TileList
- TileOrientation
- Timer
- TitleWindow
- TitleWindow (Spark)
- TLF
- ToggleButton (Spark)
- ToggleButtonBar
- ToolTip
- Transition
- Tree
- TruncationOptions
- UIComponent
- UIFTETextField
- Updater
- URLLoader
- URLRequest
- URLUtil
- URLVariables
- ValidationResultEvent
- Validator
- Validators
- VBox
- VDividedBox
- Vector
- VerticalLayout
- VerticalLayout (Spark)
- VGroup (Spark)
- Video
- VideoDisplay
- VideoElement
- VideoElement (Spark)
- VideoEvent
- VideoPlayer (Spark)
- VideoPlayerScrubBar
- ViewStack
- VScrollBar (Spark)
- VSlider
- VSlider (Spark)
- XML
- XMLList
- XMLListCollection
- ZipCodeValidator
- ZipCodeValidatorDomainType
- Zoom
-
Articles
- December 2010
- November 2010
- October 2010
- September 2010
- August 2010
- July 2010
- June 2010
- May 2010
- April 2010
- March 2010
- February 2010
- January 2010
- December 2009
- November 2009
- October 2009
- September 2009
- August 2009
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
-
Meta


Hi peter,
I’ve just searched through your whole blog, and couldn’t find your email address. I have a question that I would like to ask regarding dataProviders, since it’s causing problem within my application.
Thanks,
Dhawan,
The best place to ask Flex related questions is on FlexCoders.
Peter
Hi,
I really like your blog. Great and helpful posts. But recently it seems like your are not posting any more visible examples. Why? I guess, you could even post examples created with Flex Gumbo and simply mark them as Beta and other requirements.
Keep up the good work!
Hello,
I simply love this site, it’s full of infos.
But I have a question, as I’m very new to flex…thought you could help since all your examples are well explained. I’m sorry if it doesn’t fit in this but still it is datagrid related.
How is is possible to add a combobox in the header (for filtering) AND to keep the standard header that sorts acending or descending ?
I’m quite desperate about this, I’ve found a way to put comboboxes, but then it erases the header itself. I’d really need the two functionnalities in the header…
Thanks in advance if you can help on this matter :)
Regards
Jfk003,
I’ve never tried that (and I’m not sure how it would work since how would the header know if clicking on the ComboBox should sort the column or open the ComboBox drop down menu)…
The best place to ask would probably be the FlexCoders mailing list.
Peter
Jfk003,
You should be able to do this with a custom renderer. The way I would do it is to add 2 children to the header, the combobox and a something like a picture of an arrow. I’d then add event listeners to both and catch them seperately. This way you can handle the click in both places. One for sort and one for the combobox.
Good luck.
Hi Peter,
Is it possible to use the same for AdvancedDataGrid ??