I have a complex screen that consists of a number of DGs shown side by
side that creates an illusion of a single very wide DataGrid. The users
are able to select a row in one of the DG and all grids will have the
same row highlighted.
I am using this as a custom item renderer:
public class blockItemRenderer extends Label implements
IDropInListItemRenderer
Here is code that does "on" or "off" depending on data conditions:
override protected function updateDisplayList(unscaledWidth:Number,
unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
var grid1:DataGrid = DataGrid(DataGridListData(listData).owner);
if (grid1.isItemSelected(data))
{
if (g == null)
{
g = graphics;
storeBackgroundCell = getStyle("backgroundColor");
}
if (data.trainplan == true)
{
g.clear();
g.beginFill(0xe1dc4d);
g.drawRect(0, 0, unscaledWidth, unscaledHeight + 1);
g.endFill();
}
else
{
g.clear();
}
}
}
Here is code that basically triggers the updateDisplayList:
DataGrid(DGObject).selectedIndex = selectedIndex;
DataGrid(DGObject).dataProvider[selectedIndex].trainplan = addToPlan;
So far so good, it works fine.
But now the users want to save "screen". Another words they wont to be
able to bring a scrren copy back with all the highlights they have made
before they save the screen. Since everything is data driven I am
saving the whole xml that is used to build the screen in the first palce
to a database and simply send it back when they request a copy.
Unfortunatelly no hightlight cells are shown when a screen copy is
loaded.
I am trying to force the updateDisplayList by doing this:
override public function set dataProvider(value:Object):void
{
super.dataProvider = value;
if(dataProvider != null && value != null && dataProvider is
ICollectionView)
{
var cursor:IViewCursor =
(dataProvider as ICollectionView).createCursor();
var cnt:int = 0;
while (!cursor.afterLast)
{
if (cursor.current.trainplan == true && listData != null)
{
DataGrid(listData.owner).selectedIndex = cnt;
Alert.show(cnt.toString());
}
cnt++;
cursor.moveNext();
}
}
}
But the Alert box is not even popping up I think because listData is
null.
Any idea that might help?