2 Replies Latest reply on Sep 14, 2007 2:32 AM by hungn

    the proplem about the variableRowHeight property of the control List

    hungn
      hi all
      i used the control List and i had one the proplem,
      list1 is good, i can use the variableRowHeight property to make the height of List control rows variable based on their content. but list2 is not true, i supposed that the proplem is <mx:HBox>,but i have to use it for many fields(for example : Linkbutton,button..)
      this is code:

      <?xml version="1.0"?>
      <!-- dpcontrols/ListLabelFunction.mxml -->
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" >
      <mx:Script><![CDATA[
      public function myLabelFunc(item: Object):String {
      return item.text ;
      }
      ]]></mx:Script>

      <mx:ArrayCollection id="myDP">
      <mx:source>
      <mx:Text text="this is the code for Setting variable row height and wrapping List text">
      </mx:Text>

      </mx:source>
      </mx:ArrayCollection>
      <mx:List id="list1" dataProvider="{myDP}" width="100" wordWrap="true" height="200" variableRowHeight="true" labelFunction="myLabelFunc"/>



      <mx:List id="list2" dataProvider="{myDP}" width="100" variableRowHeight="true" wordWrap="true" >
      <mx:itemRenderer>
      <mx:Component>
      <mx:HBox>
      <mx:Text text="{data.text}" >
      </mx:Text>
      <mx:Text text="{data.text}" >
      </mx:Text>
      </mx:HBox>
      </mx:Component>
      </mx:itemRenderer>
      </mx:List>
      </mx:Application>

      can anyone help me? thanks
        • 1. Re:  the proplem about the variableRowHeight property of the control List
          raghunathrao Level 1
          The reason is because the text width is not designated and so it overflows the HBox, spawning a horizontal scrollbar.

          The way to counter this is to size the textField, once the HBox is created. You also should set the horizontalScrollPolicy of the HBox to off. Your renderer code would look like this..

          <mx:itemRenderer>
          <mx:Component>
          <mx:HBox horizontalScrollPolicy="off" creationComplete="initSizes()">
          <mx:Script>
          <![CDATA[
          private function initSizes():void{
          var txtWidth:int = this.width/2 -(this.getStyle('paddingLeft')+this.getStyle('paddingRight')+this.getStyle('horizontalGap '));
          txt0.width = txt1.width = txtWidth ;
          }
          ]]>
          </mx:Script>
          <mx:Text id="txt0" text="{data.text}" >
          </mx:Text>
          <mx:Text id="txt1" text="{data.text}" >
          </mx:Text>
          </mx:HBox>
          </mx:Component>
          </mx:itemRenderer>

          Alternatively, you could set the paddings and horizontalGap to zero in the renderer and then say txtWidth = this.width/2;
          • 2. Re:  the proplem about the variableRowHeight property of the control List
            hungn Level 1
            thanks you for the detail info. i maded it as the answer of you.
            horizontalScrollPolicy="off",set :width of text.