This content has been marked as final. Show 4 replies
Yep, you'll have to edit it like so:
I know how to make the column width static. But I want the column width to change according to it's content. If the maximum width of the column cells is 120 I want the column width to be 120. If the maximum is 300 then I want the column width to be 300.
I read an article about how to do this a while back. I think someone created a custom class, or maybe it's in the Flex Cookbook. I will take a look and see if I can find it.
First thing that comes into my mind and to advice you, is to see how measureWidthOfItems from ListBase can be used. I quote:"
Measures a set of items from the data provider using the current item renderer and returns the maximum width found. This method is used to calculate the width of the component. The various ListBase-derived classes have slightly different implementations. DataGrid measures its columns instead of data provider items, and TileList just measures the first item and assumes all items are the same size. This method is not implemented in the ListBase class and must be implemented in the child class."
In mx.controls.List you will find the override for measureWidthOfItems - from which cames the second idea : to use an itemRenderer which include this measuring procedure (see there is IFactory object there - getItemRendererFactory).