Solved

FLEX 2 Programmatically adding DAtagrid column to a datagrid

Posted on 2006-12-01
10
980 Views
Last Modified: 2008-01-09
 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
0
Comment
Question by:Robinsonx6
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
10 Comments
 
LVL 7

Expert Comment

by:muxxter
ID: 18056724
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
0
 
LVL 2

Author Comment

by:Robinsonx6
ID: 18121533
a DataGrid doesnt appear to have a addColumn, any ideas please
0
 
LVL 7

Expert Comment

by:muxxter
ID: 18122974
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
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Author Comment

by:Robinsonx6
ID: 18123033
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,
0
 
LVL 7

Expert Comment

by:muxxter
ID: 18123363
Weird. Does it give you an error when you compile it, or does it simply not do anything when you try to run it?
0
 
LVL 2

Author Comment

by:Robinsonx6
ID: 18123393
only error is the original one i posted above it is strange
0
 
LVL 7

Accepted Solution

by:
muxxter earned 500 total points
ID: 18123560
That's for the addChildAt() I think.

Try changing that line:

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);
dg.addColumn(dc1);
...

Gav
0
 
LVL 2

Author Comment

by:Robinsonx6
ID: 18241596
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
0
 
LVL 7

Expert Comment

by:muxxter
ID: 18243850
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
0
 
LVL 2

Author Comment

by:Robinsonx6
ID: 18243965
thanks
Chris
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question