Turned out to be trickier than I thought. Here’s what I had to do.
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:local="*"
minWidth="1024" minHeight="768"
creationComplete="onCreationComplete();">
<fx:Declarations>
<fx:Component className="MyDG">
<mx:DataGrid>
<fx:Script>
<![CDATA[
public var lastHighlightItem:Object;
private var inUpdateDL:Boolean = true;
override protected function updateDisplayList(w:Number,
h:Number):void
{
inUpdateDL = true;
trace("updateDL", lastHighlightItem ?
lastHighlightItem.first : "none");
super.updateDisplayList(w, h);
inUpdateDL = false;
}
override protected function clearIndicators():void
{
var indicator:Sprite = highlightIndicator;
var uid:String = highlightUID;
super.clearIndicators();
if (inUpdateDL && lastHighlightItem)
{
trace(uid);
//highlightIndicator = indicator;
highlightUID = uid;
highlightItemRenderer = null;
}
}
]]>
</fx:Script>
</mx:DataGrid>
</fx:Component>
</fx:Declarations>
<fx:Script>
<![CDATA[
private function onCreationComplete():void
{
dg.dataProvider = [
{ first: "Alex", last: "Harui" },
{ first: "Blex", last: "Harui" },
{ first: "Clex", last: "Harui" },
{ first: "Dlex", last: "Harui" },
{ first: "Elex", last: "Harui" },
{ first: "Flex", last: "Harui" },
{ first: "Glex", last: "Harui" },
{ first: "Hlex", last: "Harui" },
{ first: "Ilex", last: "Harui" },
{ first: "Jlex", last: "Harui" },
{ first: "Klex", last: "Harui" },
{ first: "Llex", last: "Harui" },
{ first: "Mlex", last: "Harui" },
];
}
]]>
</fx:Script>
<local:MyDG id="dg" variableRowHeight="true"
itemRollOver="dg.lastHighlightItem = event.itemRenderer.data;
dg.invalidateList()"
itemRollOut="dg.lastHighlightItem = null;dg.invalidateList()" >
<local:columns>
<mx:DataGridColumn dataField="first" />
<mx:DataGridColumn dataField="last">
<mx:itemRenderer>
<fx:Component>
<mx:Label dataChange="text = data.last; invalidateSize()" >
<fx:Script>
<![CDATA[
import mx.controls.DataGrid;
override protected function measure():void
{
trace("measure");
super.measure();
var dg:MyDG = MyDG(listData.owner);
if (dg.lastHighlightItem == data ||
dg.isItemSelected(data))
measuredHeight = 40;
else
measuredHeight = 25;
trace(data.first, measuredHeight);
}
]]>
</fx:Script>
</mx:Label>
</fx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</local:columns>
</local:MyDG>
</s:Application>
On 7/30/10 1:27 PM, "[email protected]" <[email protected]> wrote:
Correct. I can accomplish that with the following....
override protected function updateDisplayList(w:Number,h:Number):void
{
var dg:DataGrid = DataGrid(listData.owner);
if (dg.isItemHighlighted(data) ||
dg.isItemSelected(data) ) {
super.height=40;
}
else{
super.height=25;
}}
but I loose the rollover color on the datagrid.
Alex Harui <[email protected]>
Sent by: [email protected] 07/30/2010 12:56 PM
Please respond to
[email protected]
To
"[email protected]" <[email protected]>
cc
Subject
Re: [flexcoders] change datagrid rowHeight on rollover
Normally you only want to change one row’s height so you do that with an
itemRenderer.
On 7/30/10 10:22 AM, "joegjames" <[email protected] <[email protected]> >
wrote:
Is it possible to change the rowHeight on rollover? Does it have to be done
from with in an itemRenderer?
--
Alex Harui
Flex SDK Team
Adobe System, Inc.
http://blogs.adobe.com/aharui