Title: RE: Adding columns dynamically in a datagrid

Hi Sathish,

 

You need to build your new columns array locally in the function and then assign this array to dataGrid.columns. This is because the columns property returns a copy of the DataGrid’s columns array.

 

Eg:

 

        var newColumns : Array = new Array();

       

        // Add all your new columns to the newColumns array

 

        myGrid.columns = newColumns;

 

Paul

 


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Pottavathini, Sathish
Sent: Wednesday, July 19, 2006 7:51 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] RE: Adding columns dynamically in a datagrid

 

Sample Code:

        var len:int = xml_itemCount.children()[0].children().length();
        var ttle:String = '';
        grid_Reports.columns = [];
        for (var i:int=0; i<len; i++)
        {
                var itm:Object = xml_itemCount.children()[0].children()[i];
                ttle = [EMAIL PROTECTED];
                if (ttle.length == 0)
                        ttle = itm.name();
                       
                trace(itm.name() + "=" + itm.text());
                var tmp:DataGridColumn = new DataGridColumn(itm.name());
                tmp.dataField = itm.name();
                tmp.headerText = ttle + " - " + i;
                grid_Reports.columns[i] = tmp;
               
                trace(grid_Reports.columns.length);
        }

_____________________________________________
From:   Pottavathini, Sathish 
Sent:   Wednesday, July 19, 2006 11:48 AM
To:     flexcoders@yahoogroups.com
Subject:        Adding columns dynamically in a datagrid

I have a datagrid and the data loaded into it is dynamic. The number of columns are also different each time. So I am trying to read the xml data that is used for the datagrid and create columns at run time using 'columns' property of the datagrid. But for some reason it's not creating those columns in datagrid. Am I missing anything?

Any sample code for this kinda thing?

Thanks
Sathish

__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




__,_._,___

Reply via email to