In my last post I presented a simple way to customise the DataGridItemRenderer
class so the Flex DataGrid
control would use the textRollOverColor
and textSelectedColor
styles correctly. But I
also noted that the solution would not fix the DataGrid
header items... well, here's my solution to that problem.
First of all, it's worth noting that there are two main reasons why a custom DataGridItemRender
is not adequate for
the DataGrid
header items. The first reason is that the renderer's validateNow()
method is almost never called for
header items, even though it also called correctly, and often, for the data items. And the second reason is this: the
validateNow()
method (both the original version, and my custom version) depends on two DataGrid
methods in order to
determine which text style to use. Those methods are isItemHighlighted()
and isItemSelected()
. However, neither of
those methods work for header items - they both always return false, making them of no use in determining text color for
header items.