Why does my AS3 DataGrid with sortable columns show the wrong movie clip loaded in the cell after sorting?

I have a datagrid component in my AS3 project and I have a special cell rendering assigned to a single column that loads a movie clip into a cell depending on the data value of that cell. For example, if the cell data is number 1, I load movieclip1, if 2 I load movieclip2. This works great. In the CustomCellRenderer class, I use

public function set data(value:Object):void { _data = value; // value.Number is the value that I use to determine which movie clip to show in this cell source = "movie"+value.Number; } 

When the DataGrid loads, the correct movie clip is loaded into the cell. However, when the user sorts the columns by clicking on the column heading, some of the movie clips do not load. I checked that the data is sorted in order, and when I trace the "movie" + value. The number displays the correct line.

I think maybe I need to unload the video clips in each cell before setting the source again? How to do it?

Another thing I noticed is that when a DataGrid needs to be scrolled because there are more lines on the screen than on the screen (duh!), Only one set of movie clips will be displayed at once, as if there is an “active”, or " focus ", which will only show video clips. Again, I assume that Flash tries to show only the clips that are in the visible part of the scrollable DataGrid, and tries to update every time I scroll. However, only 1 cell shows movie clips, and not the entire visible part (about 8 lines).

thanks

+4
source share
1 answer

It may have something to do with datagrid socket virtualization, as it is trying to optimize scroll performance and is redesigning cell layout. Try setting the virtual layout to false, maybe this will help.

0
source

All Articles