Feb 15
Issues with Flex DataGrid and custom ItemRenderers
Posted by James Netherton | Friday 15 February 2008 6:48 PM | In Flex
I've just finished implementing a work around for some problematic behaviour I came across within the Flex DataGrid. I have a user interface which has a DataGrid with custom item renderers so that combo boxes can be rendered within DataGrid cells. In order to set the combo box selected index to it's appropriate value, I was invoking some custom code on the combo creationComplete event.
Some freaky things were happening when data within the grid was being refreshed. Some of the combo selected values were not in the order I expected them to be in.
After doing some digging, it seems that DataGrid ItemRenderers are reused for performance reasons. This is a problem if using the creationComplete event.
The solution is to override the container 'data' setter property method, with an implementation like the following:
super.data = value;
if(value == null){
return;
}
//Further custom logic here....
}
There's a great overview of the problem over at Steve Kamerman's Blog. There's also a nice working example here.
Some other blog posts that helped are:
Flex DataGrid ItemRenderers Explained
Item Renderers in DataGrids - A Primer for Predictable Behavior
0 Comments
[Post comment]