I did this as a somewhat hardcoded solution, I only have a few sections in the app so if this helps anyone or if anyone knows a more efficent way:
var arrayToMatch:Array = new Array ("id", "disabled", "date", "title", "content"); // var tmpArray:Array = new Array(); // datagridColumns = datagrid.columns; // for(var i:Number=0; i<arrayToMatch.length; i++) { for(var j:Number=0; j<datagridColumns.length; j++) { if(arrayToMatch[i]==datagridColumns[j].headerText) { trace(arrayToMatch[i], "MATCHES", datagridColumns[j].headerText); tmpArray.push(datagridColumns[j]); } } } datagrid.columns = tmpArray; Thanks for the heads up on the DataGridColumns, this is my first data driven Flex app and anything helps... --- In flexcoders@yahoogroups.com, "Alex Harui" <[EMAIL PROTECTED]> wrote: > > You probably have to get children() from the XML and create your own > array of DataGridColumns at runtime. > > ________________________________ > > From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On > Behalf Of jason vancleave > Sent: Tuesday, March 27, 2007 1:19 AM > To: flexcoders@yahoogroups.com > Subject: [flexcoders] Sorting Datagrid column headers > > > > I am using a DataGrid with a dataprovider of xml. This is working > fine with the exception of the column headers being ordered > alphabetically instead of copying the XML structure. > > The DataGrid would format the following xml with column headers in > the order of > disabled, id, media, ordernumber, title > > The docs in DataGrid.columns talks about a way to "explictly set" > this but I can't find a good example. I am thinking maybe there is an > easier way to sort the data higher up the chain. > > Thanks, > Jason > > <?xml version="1.0" encoding="UTF-8"?> > <root> > <gallery> > <item> > <id>1</id> > <disabled>0</disabled> > <title>HomeContent</title> > <ordernumber>0</ordernumber> > <media>AVLibrary2.swf</media> > </item> > <item> > <id>2</id> > <disabled>0</disabled> > <title>HomeContent</title> > <ordernumber>1</ordernumber> > <media>reelcutweb.jpg</media> > </item> > <item> > <id>3</id> > <disabled>0</disabled> > <title>HomeContent</title> > <ordernumber>2</ordernumber> > <media>OMARBONELESSAD.jpg</media> > </item> > </gallery> > </root> >