Hi.

I'm using an itemRenderer in a datagrid. The renderer contains a
script, which will determine specific values in the {data} and
setStyle on a canvas and the text of a string.

But when I scroll in the datagrid, it seems like new children is not
updated when they become visible.
I'm sure that this is due to something I'm unaware of how to do
correctly. But I havent been able to find any posts/articles on how to
do this correct.

Here's a copy of my itemRenderer - if someone has a good link or
pointer I'd be very happy to hear from you.

Thanks for your time.

Mark

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"; width="130"
height="228">
<mx:Script>
        <![CDATA[
                import mx.controls.Alert;
                private function imgresize():void {
                        if (this.img.height > 180) { this.img.height = 180 };
                        if (this.img.width > 125) { this.img.width = 125 };
                }
                
                private function setState(state:String):String {
                        this.indicator.visible = true;
                        this.status.visible = true;
                        if (state == '1'){
                                this.img.toolTip = "Godkendt";
                                
this.indicator.setStyle("backgroundColor",0x00ff40);
                                return "Godkendt";
                        } else if (state == '2') {
                                this.img.toolTip = "Korrektur";
                                
this.indicator.setStyle("backgroundColor",0xff0000);
                                return "Korrektur";
                        } else if (state == null) {
                                this.img.toolTip = "Intet";
                                this.indicator.visible = false;
                                this.status.visible = false;
                        }
                        return "";
                }
                
                private function setSelectedItem() : void
                {
                        this.parentApplication.g_arrPageItem =
this.parentApplication.thumbTile.selectedIndex;
                
parentApplication.switchPage(data.bf,data.pdfref,data.zoomref,data.pageno,data.pagecount,data.id);
                }
        ]]>
</mx:Script>
        <mx:Canvas width="125" height="200" horizontalCenter="0"
borderStyle="solid" themeColor="#ffffff" borderColor="#000000"
cornerRadius="5" backgroundColor="#eeeeee" bottom="0">
                <mx:Image id="img" source="{data.fn}" horizontalCenter="0"
scaleContent="true" autoLoad="true" updateComplete="imgresize();"
buttonMode="true" click="setSelectedItem();" showEffect="Iris" top="2"/>
                <mx:Label id="lbl" text="{data.pageno}" horizontalCenter="0"
bottom="5" color="#000000" fontSize="14"/>
        </mx:Canvas>
        <mx:Canvas width="125" height="25" cornerRadius="5"
borderStyle="solid" id="indicator" horizontalCenter="0" top="0">
                <mx:Label text="{setState(data.state)}" id="status" 
fontSize="14"
color="#000000" horizontalCenter="0" bottom="0"/>       
        </mx:Canvas>
</mx:Canvas>


Reply via email to