following  link looks like what you need.
Another variation is to use TextMetrics to figure out the size of the text.

hth
cheers  Steve Anson

http://groups.google.com/group/flex_india/browse_thread/thread/7b546ff1cf7f94b8?pli=1

--- In flexcoders@yahoogroups.com, "valdhor" <valdhorli...@...> wrote:
>
> I never found any examples on the web.
> 
> I am trying to do this now and have my own strategy which may or may not be 
> the best. In my case, my Data Grid has a max of around 30 rows - I don't 
> think my strategy would work for large data sets.
> 
> So, what I am thinking is to use a mono-spaced embedded font for the data 
> grid (I am using Apple's Monaco TrueType font). Seeing as I know the font 
> size I will be using and each character uses the same width, I can safely use 
> a simple calculation to get the width of the column. I send a separate 
> request to the server that returns an object that contains the max character 
> length for each of the fields. In FLex I create columns from this object and 
> set the datagrid's columns to this array.
> 
> Once I have this working, I will post an example.
> 
> 
> 
> --- In flexcoders@yahoogroups.com, Alex Harui <aharui@> wrote:
> >
> > I don't know of any, but this question has been asked so many times, 
> > there's probably an example if you search the web.
> > 
> > 
> > On 5/25/10 10:36 AM, "method_air" <loudjazz@> wrote:
> > 
> > 
> > 
> > 
> > 
> > 
> > Any 'resize data grid columns to content' code examples?
> > 
> > --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> , 
> > Alex Harui <aharui@> wrote:
> > >
> > > The column has to be the same size for every row, but each column can 
> > > have different widths.  It would be rare to set it from the itemrenderer, 
> > > usually some other code accesses datagrid.column[i].width.
> > >
> > >
> > > On 5/19/10 11:02 AM, "method_air" <loudjazz@> wrote:
> > >
> > >
> > >
> > >
> > >
> > >
> > > How do you vary the data grid column widths? Setting the width property 
> > > inside the item renderers to different values is not working.
> > >
> > > Thanks,
> > >
> > > Philip
> > >
> > >
> > >
> > >
> > >
> > >
> > > --
> > > Alex Harui
> > > Flex SDK Team
> > > Adobe System, Inc.
> > > http://blogs.adobe.com/aharui
> > >
> > 
> > 
> > 
> > 
> > 
> > 
> > --
> > Alex Harui
> > Flex SDK Team
> > Adobe System, Inc.
> > http://blogs.adobe.com/aharui
> >
>


Reply via email to