Well, dg.columns is an Array not an ArrayCollection so there is no need
to assign it as one. I'm actually surprised the assignment worked.
Anyway, you may have to make entirely new columns and copy properties
from the old one. That would look something like:
var c:Array = dg.columns.
var newCols:Array = new Array;
for (var i:int = 0; i < c.length; i++)
{
Var col:DataGridColumn = new DataGridColumn;
col.dataField = c[i].dataField.
col.width = c[i].width;
}
dg.columns = newCols;
If you can make a small example we can try to take a closer look.
________________________________
From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of fudongli
Sent: Monday, March 19, 2007 11:04 PM
To: [email protected]
Subject: [flexcomponents] Re: DataGrid column width problem
Alex,
Sorry that I reply you so late.
You wrote me following code:
var c:Array = dg.columns;
fixupWidths(c);
dg.columns = c;
Was it a typo that you used array instead of a ArrayCollection.
I did in the following way, not working:
var cols:ArrayCollection = dg.columns;
cols.getItemAt(5).width = 60;
dg.columns = cols;
It was not working, telling me following errors:
A term is undefined and has no properties.
at
mx.controls::DataGrid/http://www.adobe.com/2006/flex/mx/internal::res
<http://www.adobe.com/2006/flex/mx/internal::res>
izeColumn()
at mx.controls.dataGridClasses::DataGridColumn/set width()
Please forgive me if I made a simple mistake. I am still learning.
Thanks,
Fudong
--- In [email protected]
<mailto:flexcomponents%40yahoogroups.com> , "Alex Harui" <[EMAIL PROTECTED]>
wrote:
>
> The workaround would depend on the situation. You might just take
the
> .columns, set new widths for all of them and re-set them
>
>
>
> var c:Array = dg.columns;
>
> fixupWidths(c);
>
> dg.columns = c;
>
>
>
> If you can reproduce the problem in 20 lines of MXML we can take a
> closer look.
>
>
>
> -Alex
>
>
>
> ________________________________
>
> From: [email protected]
<mailto:flexcomponents%40yahoogroups.com>
> [mailto:[email protected]
<mailto:flexcomponents%40yahoogroups.com> ] On Behalf Of fudongli
> Sent: Sunday, March 18, 2007 11:00 PM
> To: [email protected]
<mailto:flexcomponents%40yahoogroups.com>
> Subject: [flexcomponents] Re: DataGrid column width problem
>
>
>
> Alex,
>
> I really appreciate your reply. What kind of workaround are you
> suggesting? One way to do it would be to create the whole datagrid
in
> a dynamic way. This is not my code. I would have done that at the
> beginning. I will suggest them to create the datagrid in a dynamic
> way. It seems there is no a lot changes.
>
> Regards,
>
> Fudong
>
> --- In [email protected]
<mailto:flexcomponents%40yahoogroups.com>
> <mailto:flexcomponents%40yahoogroups.com> , "Alex Harui" <aharui@>
> wrote:
> >
> > This issue was addressed in an updater due out soon (probably a
month
> or
> > two), so you can wait until then or we can try to find a
workaround.
> >
> >
> >
> > -Alex
> >
> >
> >
> > ________________________________
> >
> > From: [email protected]
<mailto:flexcomponents%40yahoogroups.com>
> <mailto:flexcomponents%40yahoogroups.com>
> > [mailto:[email protected]
<mailto:flexcomponents%40yahoogroups.com>
> <mailto:flexcomponents%40yahoogroups.com> ] On Behalf Of fudongli
> > Sent: Saturday, March 17, 2007 4:32 PM
> > To: [email protected]
<mailto:flexcomponents%40yahoogroups.com>
> <mailto:flexcomponents%40yahoogroups.com>
> > Subject: [flexcomponents] DataGrid column width problem
> >
> >
> >
> > Guys,
> >
> > We have a stupid problem here. In one of datagrid developed by
our
> > developers, there are a few columns need to be added dynamically
> > besides 5 basic column. The width of the grid is 800. So before
the
> new
> > columns are added dynamically, the last column takes width of
800-
> > 4*columns though it is given a fixed column. This is fine. But
after
> the
> > new
> > columns are added, the width of this column still stays same.
You have
> > to
> > drap the column to see new columns. I tried to redefine the
column's
> > width
> > dynamically, but following code is not working:
> >
> > datagrid.columns[5].width = 60;
> >
> > It caused errors. Tried percentWidth, also not working. Did I do
> > something
> > wrong? How can I fix this issue?
> >
> > Many thanks,
> >
> > Fudong
> >
>