Thursday, May 15, 2008

Flex 3 - Get the text of your DataGrid Item

The task (which you would really think should be simple) is to get the text of the current DataGrid element in a custom drop-in itemRenderer. This can be useful for a lot of reason - for me specifically, I wanted to use the same renderer for an entire DataGrid and color things one color if they're less than 5 and another if they are more than 5. But to do that, you have to create an itemRenderer that knows which column it is in in order to retreive the correct data. Sadly, this took me several hours of searching and not only could I not find any proper solutions, but I ran across a number of dated examples that sent me in the wrong direction.



So, without further ado, getting the text of your DataGrid item in an ItemRenderer:


private function getItemText():Object
{
return data.elements(getColumn().headerText);
}

private function getColumn():DataGridColumn
{
var dg:DataGrid = (listData) ? DataGrid(listData.owner) : null;
var column:DataGridColumn = (dg) ? dg.columns[listData.columnIndex] as DataGridColumn : null;

return column;
}

Tuesday, May 06, 2008

Yet another reason to choose bittorrent...


I wish Hulu had been done right, but seriously, when it is *easier* to pirate than to "do the right thing" something is just wrong with your business model.