3 Replies Latest reply on Jan 19, 2007 12:06 PM by michael_ramirez44

    ItemRenderer Bug?

    michael_ramirez44 Level 1
      I have been struggling with this issue for about 2 weeks. I was able to reproduce it in a small example. I add and remove an itemRenderer to a datagrid column at run-time. This only won't cause the RTE but I also set the datagrids dataProvider again which causes the error. You will need the Flash Player Debug version to actually see the error. You can view the example application here. I have also include the source with this post.

      --- App.mxml ---
      <?xml version="1.0"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" creationComplete="initApp()">
      <mx:Script>
      <![CDATA[
      import mx.collections.*;

      public var renderer:ClassFactory;

      public function initApp():void
      {
      loadData(10);
      }

      public function loadData(rows:uint):void
      {
      var gridData:ArrayCollection = new ArrayCollection();
      for( var x:int = 0; x < rows; x++)
      {
      var vo:Object = new Object();
      vo.fname = "John" ;
      vo.lname = "Doe";
      vo.job = "Programmer";
      gridData.addItem(vo);
      }

      dg.dataProvider = gridData;
      }

      public function withRenderer():void
      {
      renderer = new ClassFactory(LinkRenderer);
      fname.itemRenderer = renderer;
      loadData(50);
      }

      public function withOutRenderer():void
      {
      fname.itemRenderer = null;
      loadData(100);
      }
      ]]>
      </mx:Script>
      <mx:TextArea text="To reproduce bug click 'With Item Renderer' and then scroll datagrid!" width="300"/>
      <mx:HBox>
      <mx:Button id="wBtn" click="withRenderer()" label="With Item Renderer"/>
      <mx:Button id="woBtn" click="withOutRenderer()" label="WithOut Item Renderer"/>
      </mx:HBox>
      <mx:DataGrid id="dg" width="300" height="400">
      <mx:columns>
      <mx:DataGridColumn id="fname" dataField="fname" headerText="Firstname" />
      <mx:DataGridColumn id="lname" dataField="lname" headerText="Lastname" />
      <mx:DataGridColumn id="job" dataField="job" headerText="Job Description" />
      </mx:columns>
      </mx:DataGrid>
      </mx:Application>

      --- LinkRenderer.mxml --
      <?xml version="1.0" encoding="utf-8"?>
      <mx:HBox xmlns:mx=" http://www.adobe.com/2006/mxml" width="100%" height="100%" horizontalAlign="left">
      <mx:Script>
      <![CDATA[

      ]]>
      </mx:Script>
      <mx:LinkButton id="linkBtn" label="John"/>
      </mx:HBox>