Solved

FLEX 2 Programmatically adding DAtagrid column to a datagrid

Posted on 2006-12-01
10
978 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
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 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.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

828 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