Search Flex Components Free

Custom Search

December 10, 2007

DataGrid CellRenderer V2 Error

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;
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.

Related Flex Tutorials