2 Replies Latest reply on Aug 25, 2011 10:37 PM by Wang4181

    AdvancedDataGrid scrolling up issue

    Wang4181 Level 1

      Hi,

       

      I have a AdvancedDataGrid that display a hierarchy source, there is one issue that when scrolling up from bottom, the item are repeating,

      such as : pciture 1 (currect display the hierarchy), pciture 2 (items are repeated after scrolling up), picture 3 (the expected display)

      picture 1.png picture 1

      picture 2.png picture 2

      picture 3.png picture 3

       

      Here is the definition for the AdvancedDataGrid:

       

      <mx:AdvancedDataGrid id="layer_datagrid" headerHeight="0"

      editable="true" selectable="true" verticalGridLines="false"

      iconFunction="{null}" folderClosedIcon="{null}" folderOpenIcon="{null}" >

       

      <mx:dataProvider>

       

      <mx:HierarchicalData source="{this.layerList}"/>

       

      </mx:dataProvider>

       

      <mx:columns>

       

      <mx:AdvancedDataGridColumn id="empty_Col" editable="false" draggable="false" width="50"/>

      <mx:AdvancedDataGridColumn id="layersName_col" dataField="name" editable="false" itemRenderer="com.woodwing.digitalmagazine.views.renderers.LayerNameRenderer" draggable="false"/>

       

      <mx:AdvancedDataGridColumn id="layersCheckBox_col" dataField="selected" editable = "false" itemRenderer="com.woodwing.digitalmagazine.views.renderers.LayerRenderer" width="18" headerText="" resizable="false" draggable="false"/>

       

      </mx:columns>

       

      Definition for the LayerNameRenderer

       

      <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"

      width="100%" height="60" >

      <mx:Script>

      <![CDATA[

      import com.LayerItemVO;

       

       

      ]]>

      </mx:Script>

      <mx:HBox>

      <mx:HBox id="indent" width="{LayerItemVO(data).indent}"/>

       

      <mx:HBox>

       

      <mx:HBox id="color" backgroundColor="{LayerItemVO(data).layerColor}" width="9" height="14"/>

       

      <mx:Label id="layerNameInUse" height="18" enabled="{LayerItemVO(data).enabled}" text="{LayerItemVO(data).name}"/>

       

      </mx:HBox>

       

      </mx:HBox>

      </mx:Canvas>

       

      Please provide any hint to solve this issue.

       

      p.s. I need to define an empty column (id=empty_col), otherwise the enabled on layerRenderer dose not work.

       

      Thanks.

        • 1. Re: AdvancedDataGrid scrolling up issue
          Sree_D Level 2

          I think this is because renderers are recycled and may not change unless the binding is proper etc. verify how the data variables are getting set in renderers when scrolled up and also try overriding methods to check if you are resetting the values also I think the first column should be group item renderer as you are using HierarchicalData.

          • 2. Re: AdvancedDataGrid scrolling up issue
            Wang4181 Level 1

            Sree_D,

             

            I defined the hierarchy source for renderer as Bindable object, such as

             

            this.LayerList is ArrayCollection of LayerItemVO

             

            [Bindable]

            public class LayerItemVO {

             

                 public var children:ArrayCollection;

             

                 public var name:String = "";

             

                 public var layerColor:uint = 0x0;

             

                 public var enabled:Boolean = true;

             

                 public function LayerItemVO () {

             

                      this.children = new ArrayCollection();

             

                 }

             

            }

             

             

            You also see the definition of LayerNameRenderer in previous post.

             

            Do you see any problem on the code snippet?

             

            I have tried to follow what Adobe taught about how to define the AdvancedDataGrid, and still not know why the renderer didn't get updated when scrolling up/down. The AdvancedDataGrid did display the hierarchy data correctly.

             

            Can you let me know how to verify the data are getting set in renderers when scrolled up/down? Is there any event followed the scrolling?

            Maybe I can write out some log on this event.

             

            Also you mentioned that the first column should be group item renderer, can you give me example how to define a group item renderer?

             

            Thanks.