TrajiklyHip - Blog - The Personal Blog of Aaron West
Principle Centered Leadership by Stephen Covey         Three Signs of a Miserable Job by Patrick Lencioni         Crusaders Cross by James Lee Burke         The Chronicles of Narnia by C.S. Lewis         The Assault on Reason by Al Gore         Books I've recently read and recommend!
November 3, 2006

I'm still working through some minor DataGrid issues with custom ItemRenderers. Through reading various blogs and posts on FlexCoders, I came across the absolute best explanation of how DataGrids work behind-the-scenes. Ben (sorry I don't know his last name) has posted a sample DataGrid / ItemRenderer application where he explains how DataGrids operate on and display data from their data providers. Here is an excerpt from his posting:

from Ben's blog posting

If your DataGrid's dataProvider has 100 items, but it is only big enough to display 10 at any given time, the DataGrid only actually draws 10 items, in order to maximize performance. When you scroll the DataGrid there aren't any new items being drawn, it is simply swapping the data properties between the already drawn items. So scrolling down one row means that the piece of data for the second item is switched to be the data for the first item, the second item receives the third item's data, and so on and so on. During these reassignments, things like whether or not the CheckBox should be checked get all messed up. Some get checked, some get unchecked... its completely unpredictable. To handle this problem, we must override the data's setter method and use our own logic to determine whether or not the CheckBox should be checked.

What a clear explanation of how things work! As I mentioned earlier I'm still working through some issues with my application. I'll be finishing it up over the next few days at which point I'll be posting a follow-up to my previous "DataGrid Woes" post.

Related Blog Entries

TweetBacks
There are no TweetBacks for this entry.
Comments
Ben's Gravatar Hey Aaron, just wanted to let you know that during the exploration for my latest post I discovered the solution for your "one itemRenderer updates another" issue. If you make the whole class that is used in your dataProvider (PersonVO or whatever) Bindable, and update the values in the data override of one, the other should automatically update, as long as you've correctly overridden the data method in it. Make sense?
# Posted By Ben | 11/17/06 3:14 PM
pankaj's Gravatar Nice reserch buddy ! buck up ! But i m facing another problem
with data Grid that i create a grid at run time now i want to
item render component at run time if any body have solution then plz inform
# Posted By pankaj | 3/7/07 12:44 AM
Brian Russel Davis's Gravatar OMG! This was f'ing driving me crazy. I am not using the DataGrid but the List Component and the same madness is happening with simple stuff like graphics and other vars. This post seems old but the problem still remains. I wonder should we get a discount from Adobe every time we run into a problem like this and it makes us lose clients, time, or revenue? LOL. Never would happen. The Official Adobe Flex Blogger have to know about this stuff ... because it actually really really common for someone to use a checkbox of some type of data in a List control. In my app. I was getting duplicate items -- Items disappearing and all types of weirdness. Seems like a poorly written component -- how could it ever get out the door like that??
# Posted By Brian Russel Davis | 4/15/09 9:27 AM
Aaron West's Gravatar @Brian - Yea, this post is old but I believe the issues have been resolved with the latest mxmlc compiler. I haven't attempted to replicate this issue using old Flex Builder projects and the latest Flex SDK, but I think this is fixed. At least, if your MXML / AS3 is written a certain way.

I wound up fixing this on Flex 2 by taking some clues from other blog posts on how to wire up the item renderers and listeners better. Keep digging, I think a solution is out there for you.
# Posted By Aaron West | 4/16/09 3:58 PM
Brian Russel Davis's Gravatar Actually I am using the most up to date sdk and compiler and the issue is still around. I will post my work around for it.
# Posted By Brian Russel Davis | 4/16/09 4:04 PM
Aaron West's Gravatar @Brian - Even if you are on the latest Flex 3 SDK I believe there are ways to program your components and item renderers such that really odd behavior occurs. Item renderers have been real finicky in my experience and it's taken a lot of love and care to get them to work properly.
# Posted By Aaron West | 4/16/09 5:14 PM
Brian Russel Davis's Gravatar Yeah, sorry my response was not clear. Yes the problems do appear, AND yes I have figured it out since my original post. I will post my solutions so other who run into it can benefit.
# Posted By Brian Russel Davis | 4/16/09 5:50 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.9.3.000. Contact Blog Owner