CellularDataGrid for Flex 2
A DataGrid that supports highlighting and selection on a cellular level (as opposed to row level like the default) is a fairly common request/topic. While I realize people have done this before and this is supported out of the box by Flex 3 (sort of, see first comment below) I decided to give it a shot during some down time yesterday. I was pretty amazed at how easy it was. Even in my newline-happy code format the component is only 55 lines. The results of about 2 hours of fiddling can been seen and downloaded by following the link below.
View CellularDataGrid (Right click for source)
Hopefully someone finds this useful and/or interesting. If nothing else it should serve as an example of why diving into the framework and getting your tweak on is a worthwhile activity.
Update: Thanks to Tom‘s suggestion, the problem with the selection indicator not disappearing correctly when selecting a cell in the same row is now fixed. The example and source have been updated.
You can leave a response, or trackback from your own site.

“out of the box” only if you buy Flex 3 with DataVisualisation.
Ah, thanks for that heads up Tom. I haven’t made the jump yet and wasn’t sure.
very cool. One think I noticed though is if you select a cell in the same row as the currently selected cell, the previously selected one’s highlight doesn’t get removed until you move the mouse off that row.
Hi Rob, I did notice that and spent a few minutes trying to fix it but had no luck.
The fix for the highlight moving appears to be
for each (var sp:Sprite in selectionIndicators ){
sp.graphics.clear();
}
as the first thing in selectItem()
Thanks Tom! I will try to get that implemented when I get a chance and update the post.
This has been very useful for what I am trying to do with my project. One thing I noticed is that when you select a cell and start to scroll up/down, the selected cell is now another cell randomly. It seems like this is the issue with cell rendering being recycled? Any suggestions? Thanks.
Hi Thu,
I do see the behavior you mentioned, thanks for catching that. Unfortunately I am swamped right now and don’t really have time to investigate. If I can find some time and fix it I will be sure to let you know.
Thanks,
Ben
Hi
Fantastic. Does anyone know how to do this in Flash as3?
As far as I can see it’s only possible to return the row selected not individual cells.
This would solve a big head ache for me.
Thanks
SimpleSoul
Hi
Your code doens´t work when the propriety of the datagrid
“lockedcolumncount” is > than 0
Thanks
Lucas Gerken