3 Replies Latest reply on Jun 6, 2011 10:12 PM by FlexNaveen

    Resize item renderer when scrollbar becomes vissible

    Manystems-Arjen Level 1

      Hello,

       

      I have a component with a custom skin.

      The skin contains a list with a custom itemrenderer.

       

      When i add items to the list they are rendered perfect, until the verticalscrollbar becomes visible.

      When the bar becomes visible all items already in the list are not resized.

       

      I disabled the horizontal scrollbar since i dont want this to be visible.

       

      Is their any setting or event i can use to force all itemrenderers to invalidate their size when the scrollbar becomes visible?

       

      I tried the Resize event of the list but this does not trigger when the scollbar becomes visible.

       

      This screenshot is taken after the last item was added.

      The last item has the correct size, but the other items where not resized.

      InvalidateItemRenderer.png

       

      Thanks in advance

        • 1. Re: Resize item renderer when scrollbar becomes vissible
          Flex harUI Adobe Employee

          I believe Spark List will resize the renderers.

           

          I think the only way to do that in MX List is to set

          verticalScrollPolicy="on" if you know you have enough items.

          • 2. Re: Resize item renderer when scrollbar becomes vissible
            Manystems-Arjen Level 1

            Hmm,

             

            It is an spart list, and the items dont't resize.

             

            Here's my code:

             

            List:

             

            
            <s:List id="dgForumNotes"
                 useVirtualLayout="true"
                 itemRendererFunction="getForumNoteItemRenderer"
                 borderVisible="false"
                 dataProvider="{someList}"
                 width="100%" height="100%"
                 contentBackgroundColor="0xffffff"
                 contentBackgroundAlpha="0.4"
            >
                 <s:layout>
                      <s:VerticalLayout gap="0" />
                 </s:layout>
            </s:List>
            
            
            

             

             

            the itemRendererFunction:


             

            private function getForumNoteItemRenderer(item:Object):ClassFactory{     
                    var classFactory:ClassFactory;
                 if(item is forumNote){
                      classFactory = new ClassFactory(ProgressForumRenderer);
                      //set the property "model" of the itemrenderer with the model of this class
                      classFactory.properties = {model:hostComponent.model};
                      return classFactory;
                 }
                 //If for some reason the item is not a forumnote default itemrenderer is returned
                 return new ClassFactory(DefaultItemRenderer);
            }               
            

             

             

            and the renderer stripped version since their is some code in it:

             

            <s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" 
                                xmlns:s="library://ns.adobe.com/flex/spark" 
                                xmlns:mx="library://ns.adobe.com/flex/mx"                    
                                focusEnabled="false"
                                mouseEnabled="false"
                                autoDrawBackground="false"
                                height="100%" 
                                width="100%">     
                 <fx:Script>
                      <![CDATA[               
                           override public function set data(value:Object):void{
                                super.data = value;
                                Some data checks here
                                this.currentState = getState();
                           }
                           override protected function getCurrentRendererState():String{
                                //note: test if data is not null otherwise getState() will return a null pointer exception
                                if(data)
                                     return getState();                    
                                return super.getCurrentRendererState();
                           }
                           protected function getState():String {                    
                                determine state here
                           }
                      ]]>
                 </fx:Script>
                 <fx:Declarations>
                      <mx:DateFormatter id="dateFormatter" formatString="DD-MM-YY HH:NN:SS"/>
                 </fx:Declarations>
                 <s:states>
                      <s:State name="Description"/>
                      <s:State name="New"/>
                      <s:State name="Reply"/>
                      <s:State name="WithQuote"/>
                      <s:State name="WithNestedQuote"/>
                 </s:states>
                 
                 <Layout stuff in here>
                      
            </s:ItemRenderer>
            
            • 3. Re: Resize item renderer when scrollbar becomes vissible
              FlexNaveen

              Hi,

               

                try with useVirtualLayout as false, because when useVirtualLayout is true the itemRenderer uses the same instance