Link to home
Start Free TrialLog in
Avatar of Robinsonx6
Robinsonx6Flag for Mauritius

asked on

FLEX 2 Programmatically adding DAtagrid column to a datagrid

 hi im using the following code to try to add a datagrid column to a datagrid
       var dg:DataGrid = new DataGrid();
         dg.width=ca_prop_detail.width;
         dg.height=ca_prop_detail.height;
         
         var dc1:DataGridColumn = new DataGridColumn("DateRange");
         dg.addChildAt(dc1,0);

but i keep getting an error saying

1067: Implicit coercion of a value of type mx.controls.dataGridClasses:DataGridColumn to an unrelated type flash.display

please help this is very urgent
Avatar of muxxter
muxxter

Hi Robinsonx6.

addChildAt() in Flex 2 is used mainly to add components to a display. The error is basically telling you that a DataGridColumn is not a valid component to do this with.

Instead of addChildAt(), try addColumn():

dc1 = new DataGridColumn("DateRange");
dg.addColumn(dc1);

Let me know how it turns out.
Gav
Avatar of Robinsonx6

ASKER

a DataGrid doesnt appear to have a addColumn, any ideas please
Hmm, well despite the fact that it isn't in the Flex documentation, I've seen a couple sites use it. Here's one by Alessandro "Sephiroth" Crugnola:

http://www.sephiroth.it/index.php?blogId=2005_12_06_weekly.html

He does a lot of work with Adobe, in fact he wrote several of the classes for Flash MX (and probably more).
Anyways, check it out. He creates a couple DataGridColumns and uses adColumn() to attach them to a DataGrid.

Cheerio
Gav
im not sure what is happening ,ive seen this link before, ive even created a tiny class to extend the DataGrid in Flex2 and i get no addColumn function,
Weird. Does it give you an error when you compile it, or does it simply not do anything when you try to run it?
only error is the original one i posted above it is strange
ASKER CERTIFIED SOLUTION
Avatar of muxxter
muxxter

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
mexxter im going to accept your answer, but i still dont get it for me, i think it might be a bug in flex 2
Thanks. Sorry I couldn't be of more help, but I'll keep looking.

I'm going to need this functionality too, and if I find a solution, I'll post it to this question.

Later
Gav
thanks
Chris