DataGrid CellRenderer V2 Error
DIGG IT!
7
Comments
Published
Wednesday, February 23, 2005
at
4:00 AM
.
There is an error in the V2 DataGrid CellRenderer that makes using components within the dataGrid problematic. Here is the fix.&
In Class "mx.controls.gridclasses.DataGridRow" line 165:
cell._y = (__height-cell._height)/2;
Replace this line with:
if( cell.__height == undefined ){
cell._y = (__height-cell._height)/2;
}else{
cell._y = (__height-cell.__height)/2;
}
The problem was that the cell _y coordinate was based on _height not __height for components. If you added a ComboBox or NumericStepper into a Cell, they would resize incorrectly. The ComboBox would be ok until you opened it and then resized a column. Since the _height of the cell now contains the dropdown list, the _y of the cell is thrown off shooting the cell up aboout 50px. Using __height resolves the issue, but makes it essential to defined a getPreferredHeight function in your cell renderer class.
This makes writing cell renderers for DataGrid much easier allowing just about any component to be inserted, or better many controls in a form.
Cheers and Happy CellRenderering!
Ted ;)
If you wanted to get fancy here you could also add in pixel snapping for cell content using Math.round. Cheers, ted ;)
Actually make that Math.floor since that is what is used for the drawing API calls in drawing the background.
Yeah, we got this bug for the Flex release, AFAIK. Good catch.
nig
Thanks Nigel. Cheers, Ted ;)
Thanks, this bug was driving me up the wall :)
Would this be the same as working with a listcomponent? I've got a list that has a cellrenderer with a loader component in it, and it starts off as halfway down the item; upon a rollover it fixes itself.
Gary,
That sounds like the exact error.
Ted ;)