1 Reply Latest reply on May 24, 2007 3:38 PM by peterent

    Determine height of list with variableRowHeight

      If I have a list that is being dynamically populated with items of a variable height (an item renderer that is essentially several items with a header and a variable length body text), is there any way to determine the absolute height of the entire list? Or better still, a simple way to make the list height exactly as tall as its contents? Setting the rowCount to the number of entries doesn't work, it cuts off because I assume it is only multiplying through based off of the first or first few items and not considering each individually.

      Any help would be greatly appreciated!
        • 1. Re: Determine height of list with variableRowHeight
          peterent Level 2
          Since you want the List to be large enough to expose all of its elements it doesn't make sense to use a List. A major reason to use a List control is that you have more information than can be comfortably displayed in the space on the screen; the List provides scrollbars and a more efficent way to display large amounts of data.

          For your case, I'd suggest you use a VBox with a Repeater inside, using your itemRenderer for the VBox contents. If you have properly made the itemRenderer, using the data property, you should be able to use it as-is in the Repeater:

          <mx:VBox >
          <mx:Repeater id="rep" dataProvider="{sameOneAsYouUsedInTheList}">
          <yourItemRenderer data="{rep.currentItem}" ... />

          As long as you don't give the VBox a specific height (which would defeat the purpose) it will expand to hold all of the contents.