?
Solved

FLEX 2 Programmatically adding DAtagrid column to a datagrid

Posted on 2006-12-01
10
Medium Priority
?
982 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 2000 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

I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
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.
Suggested Courses
Course of the Month12 days, 11 hours left to enroll

777 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