How to color Datagrid cells/rows in flex 2
I have been looking for a easy and neat way to color a single cell or a complete row in flex 2.
Google brought me two interesting links:
1. How opaqueBackground can be used to color the background of a label itemRenderer
The comment posted by Dallas at 11/10/06 8:01, shows a way of highlighting a cell. Very simple implementation - the only problem is that the background color won't react on mouseover after the opaqueBackground is set.
2. How do you change the background cell color in a DataGrid?
Shows how to implement a colored background that react upon mouseover and selection. The implementation extends a label and overrides the 'updateDisplayList' method to draw some graphics as the background.
The last solution seems to be the one I preferred - because of the ability to see mouse effects applied to the cell. But still I liked the cleen implementation of the first one.
I couldn't resist of bringing combined solution, where I extends a Label, but listens for a Event.RENDER events instead of overriding the updateDisplayList method.
Sample Application
Sourcecode
Demonstrates how to use the renderer as a drop-in and inline itemRenderer.
<?xml version="1.0" encoding="utf-8"?> CustomItemRenderer.as Following is a CustomItemRenderer that can be extended to apply logic to decide if a cell is to be styled. package dk.jacobve { CustomItemRenderer extension Shows an implementation using E4X on a xml data element to deside if the cell is to be colored red. package dk.jacobve { |
9:09 PM
|
Labels:
Flex DataGrid Samples,
Flex Samples
|
This entry was posted on 9:09 PM
and is filed under
Flex DataGrid Samples
,
Flex Samples
.
You can follow any responses to this entry through
the RSS 2.0 feed.
You can leave a response,
or trackback from your own site.
0 comments:
Post a Comment