Solved

FLEX 2 Programmatically adding DAtagrid column to a datagrid

Posted on 2006-12-01
10
968 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
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 select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

910 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

22 Experts available now in Live!

Get 1:1 Help Now