Go Back   CodingForums.com > :: Client side development > Flash & ActionScript > Adobe Flex

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-13-2010, 06:01 AM   PM User | #1
pasensyoso_mani
New to the CF scene

 
Join Date: Sep 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
pasensyoso_mani is an unknown quantity at this point
Advance DataGrid on the-fly

Hi there coders,

I'm learning flex about a week or two. Am using Flex 4, may I ask some guidance of creating a component on-the-fly particularly an advancedatagrid object.

This advancedatagrid will have an advancedcolumn and advancecolumngroup on it. Please show me the right way to do this on-the-fly.


Best Regards!
pasensyoso_mani is offline   Reply With Quote
Old 09-13-2010, 06:33 AM   PM User | #2
Inigoesdr
Super Moderator


 
Inigoesdr's Avatar
 
Join Date: Mar 2007
Location: Florida, USA
Posts: 3,601
Thanks: 2
Thanked 397 Times in 390 Posts
Inigoesdr is a jewel in the roughInigoesdr is a jewel in the roughInigoesdr is a jewel in the rough
You can see an MXML example here. This is (almost) the same thing in pure AS3:
Code:
import mx.collections.ArrayCollection;
import mx.collections.Grouping;
import mx.collections.GroupingCollection2;
import mx.collections.GroupingField;
import mx.controls.AdvancedDataGrid;
import mx.controls.advancedDataGridClasses.AdvancedDataGridColumn;

private function init():void
{
    
    var testData:ArrayCollection = new ArrayCollection([
        {Region:"Southwest", Territory:"Arizona", Territory_Rep:"Barbara Jennings", Actual:38865, Estimate:40000}, 
        {Region:"Southwest", Territory:"Arizona", Territory_Rep:"Dana Binn", Actual:29885, Estimate:30000},  
        {Region:"Southwest", Territory:"Central California", Territory_Rep:"Joe Smith", Actual:29134, Estimate:30000},  
        {Region:"Southwest", Territory:"Nevada", Territory_Rep:"Bethany Pittman", Actual:52888, Estimate:45000},  
        {Region:"Southwest", Territory:"Northern California", Territory_Rep:"Lauren Ipsum", Actual:38805, Estimate:40000}, 
        {Region:"Southwest", Territory:"Northern California", Territory_Rep:"T.R. Smith", Actual:55498, Estimate:40000},  
        {Region:"Southwest", Territory:"Southern California", Territory_Rep:"Alice Treu", Actual:44985, Estimate:45000}, 
        {Region:"Southwest", Territory:"Southern California", Territory_Rep:"Jane Grove", Actual:44913, Estimate:45000}
    ]);

    
    var myADG:AdvancedDataGrid = new AdvancedDataGrid();
    myADG.columns = new Array(new AdvancedDataGridColumn('Territory'), new AdvancedDataGridColumn('Territory_Rep'), new AdvancedDataGridColumn('Actual'), new AdvancedDataGridColumn('Estimate'));
    
    var myGroup:Grouping = new Grouping();
    myGroup.fields = new Array(new GroupingField('Region'), new GroupingField('Territory'));
    
    var myGroupingCollection:GroupingCollection2 = new GroupingCollection2();
    myGroupingCollection.source = testData;
    myGroupingCollection.grouping = myGroup;
    myGroupingCollection.refresh();
    
    myADG.dataProvider = myGroupingCollection;
    myADG.validateNow();
    
    container.addElement(myADG);
}
"container" is the ID of the element you want to append the ADG to.
Inigoesdr is offline   Reply With Quote
Old 09-14-2010, 05:59 AM   PM User | #3
pasensyoso_mani
New to the CF scene

 
Join Date: Sep 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
pasensyoso_mani is an unknown quantity at this point
Thanks maaan...! I will test this when I get home.

Got a question. How am I going to render a textbox in the AdvancedDataGrid header or shall I say columngroup?

Last edited by pasensyoso_mani; 09-14-2010 at 06:18 AM..
pasensyoso_mani is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:42 AM.


Advertisement
Log in to turn off these ads.