Disabling item roll over highlighting in the Flex DataGrid control
Similar to the previous example, “Preventing a user from selecting an item in a Flex DataGrid control”, the following example shows how you can disable the item roll over highlight in the DataGrid control in Flex by setting the useRollOver style.
Full code after the jump.
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/02/01/disabling-item-roll-over-highlighting-in-the-flex-datagrid-control/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white">
<mx:Script>
<![CDATA[
import mx.events.ListEvent;
import mx.controls.Alert;
private function dataGrid_change(evt:ListEvent):void {
Alert.show(evt.itemRenderer.data.label, evt.type);
}
]]>
</mx:Script>
<mx:Array id="arr">
<mx:Object label="Alert" />
<mx:Object label="Button" />
<mx:Object label="ButtonBar" />
<mx:Object label="CheckBox" />
<mx:Object label="ColorPicker" />
<mx:Object label="ComboBox" />
</mx:Array>
<mx:ApplicationControlBar dock="true">
<mx:CheckBox id="checkBox"
label="useRollOver:"
labelPlacement="left"
selected="true" />
</mx:ApplicationControlBar>
<mx:DataGrid id="dataGrid"
dataProvider="{arr}"
useRollOver="{checkBox.selected}"
rowCount="4"
width="200"
change="dataGrid_change(event);">
<mx:columns>
<mx:DataGridColumn dataField="label" />
</mx:columns>
</mx:DataGrid>
</mx:Application>
View source is enabled in the following example.
As you can see, when the useRollOver style is set to false, the item row highlight is not drawn when moving your mouse over an item in the DataGrid, but the background color is drawn if you select an item. If the useRollOver style is set to true, the item row highlight is drawn when hovering over a list item.
Since useRollOver is a style, you can also set it in an external .CSS file, or in an <mx:Style /> block, as shown in the following snippet:
<mx:Style>
DataGrid {
useRollOver: false;
}
</mx:Style>
Or, you can set the useRollOver style in ActionScript, as seen in the following snippet:
<mx:Script>
<![CDATA[
private function init():void {
dataGrid.setStyle("useRollOver", false);
}
]]>
</mx:Script>
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.
17 Responses to Disabling item roll over highlighting in the Flex DataGrid control
Leave a Reply Cancel reply
-
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


I know Flash AS3 controls are not exactly the same as Flex AS3 controls, but could this same effect be achieved on a Flash DataGrid, even though they do not have a ‘useRollOver’ property?
Yep, you are correct Evan. At least, it seems to work for me…
I found that I’m unable to disable RollOver colors for the datagrid header.
I tried “useRollOver: false;” in the headerStyleName definition, but it seems to ignore it (as in your example here as well).
I find I’d rather disable rollover for the header, rather than the rows…those I do want rollovers.
hi all!
I have problem in the same “Anthony Ettinger” but i want to change rollover color for header. I don’t want the header has rollover color like on rows.
But i don’t find any properties support this problem.
If you have any solving for it, please help me! Thanks for reading my problem!
Hi,
i’ve a question for you..
i have a datagrid with various rows…some rows are emty…so for them i would disable user interaction..but only in as3 and not under mxml shortcut…
thanks in advance
regards Lollo
I am also looking for a way to have some rows disabled and not all.
It would be great if I could disable one or more rows.
A piece of code I use all the time to set programmatically the highlighted item in a component extending ListBase class: (Exemple for a Tree:)
I have made an example where I have a different roll-over color for the header of a datagrid component. Maybe this is of use to some of you. The example can be found here.
can we prevent datagrid to use default selection color of cell.
When datagrid is in edit mode, after click on cell default blue color comes to border of cell.
I want to not give any color thr , can we do this ?
thx in advanced,
abhishekchess1@gmail.com
:)
Can any body plz help me out …. I want to change the cursor style of datagrid while mouse moving over datagrid conditionally.. like for one row iant to shos hand cursor for other row i don want want .. so, can anybody me in this respect??????
@Ajaz,
This works for mx:List, but it should be the same for mx:DataGrid (I assume)…
Peter
Promoted to a full example; http://blog.flexexamples.com/2010/02/01/changing-the-mouse-cursor-when-rolling-over-items-in-an-mx-list-control-in-flex/
Peter
I set “color” of each cell in datagrid based on condition. ie based on a condition the text in the cell is either red or blue.
But for a highlighted row (either on selection or rollover) , the color of text is lost.
I have noticed that this is the case when selectionMode=”singleRow”. When selectionMode=”singleCell”, and the cell is highlighted, the color of text is not lost. Please let me know if someone has solution to this problem.
Thanks in advance
What if i need the text color to change on rollover but not the row? I still want to use the text-roll-over-color style, but kill the roll-over-color.
Thanks for any help
@Brad Manderscheid,
As long as you don’t need alternating item colors, this may work for you:
Peter
Actually, some possibly better solutions w/ mx:List at “Disabling item highlight indicator in the MX List control in Flex 3″.
Peter
Hi there,
I would like to be able to just disable the highlighting for a particular item. Let’s say the third one in the list.
Any ideas on how to achieve that?
Thanks in advance!