Solved

FLEX 2 Programmatically adding DAtagrid column to a datagrid

Posted on 2006-12-01
10
966 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
  • 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
 
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
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…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now