<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Column auto sort in Flex 2 DataGrid in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/column-auto-sort-in-flex-2-datagrid/m-p/3875655#M931584</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;are you doing it thru actionscript? how are you setting up the dataprovider? probably if you can post the code i can play around and see whats going wrong.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Raja&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 20 May 2008 20:57:41 GMT</pubDate>
    <dc:creator>athavanraja</dc:creator>
    <dc:date>2008-05-20T20:57:41Z</dc:date>
    <item>
      <title>Column auto sort in Flex 2 DataGrid</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/column-auto-sort-in-flex-2-datagrid/m-p/3875654#M931583</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm using a DataGrid that feeds from a XML generated on PHP...It works just great...The problem is that columns get auto sorted alphabetically when the DataGrid shows up...How can I prevent that from happening???&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FYI, I'm updating my Flex/PHP/SAP SE16 emulator...I got all columns but not in the same position that I'm sending them...I'm of course not specifiying COLUMNS...Just letting the DataGrid generate them for me -:)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Greetings,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Blag.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 May 2008 17:23:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/column-auto-sort-in-flex-2-datagrid/m-p/3875654#M931583</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-20T17:23:42Z</dc:date>
    </item>
    <item>
      <title>Re: Column auto sort in Flex 2 DataGrid</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/column-auto-sort-in-flex-2-datagrid/m-p/3875655#M931584</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;are you doing it thru actionscript? how are you setting up the dataprovider? probably if you can post the code i can play around and see whats going wrong.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Raja&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 May 2008 20:57:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/column-auto-sort-in-flex-2-datagrid/m-p/3875655#M931584</guid>
      <dc:creator>athavanraja</dc:creator>
      <dc:date>2008-05-20T20:57:41Z</dc:date>
    </item>
    <item>
      <title>Re: Column auto sort in Flex 2 DataGrid</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/column-auto-sort-in-flex-2-datagrid/m-p/3875656#M931585</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey Blag,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check this out : [Sorting data in DataGrid controls|http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Book_Parts&amp;amp;file=dpcontrols_062_18.html]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think this might help you. Just check the region to disable datagrid sorting on a column &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Abesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 May 2008 14:50:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/column-auto-sort-in-flex-2-datagrid/m-p/3875656#M931585</guid>
      <dc:creator>abesh</dc:creator>
      <dc:date>2008-05-22T14:50:29Z</dc:date>
    </item>
    <item>
      <title>Re: Column auto sort in Flex 2 DataGrid</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/column-auto-sort-in-flex-2-datagrid/m-p/3875657#M931586</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Abesh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I guess Blag is talking about column positioning and not about sorting the data within the column.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Blag: correct me if i am wrong.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Raja&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 24 May 2008 06:43:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/column-auto-sort-in-flex-2-datagrid/m-p/3875657#M931586</guid>
      <dc:creator>athavanraja</dc:creator>
      <dc:date>2008-05-24T06:43:22Z</dc:date>
    </item>
    <item>
      <title>Re: Column auto sort in Flex 2 DataGrid</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/column-auto-sort-in-flex-2-datagrid/m-p/3875658#M931587</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;@Raja:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your 100% percent correct -:) For example...My DD Table got this fields...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
MANDT
NAME
SURNAME
AGE
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But when the table is showed on the DataGrid it goes like...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
AGE
MANDT
NAME
SURNAME
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, it sorted alphabetically...And of course I don't want that -:( Can help??? -:D&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;@Abesh:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks anyway dude...Link was great and it's going to useful for next projects -;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Greetings,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Blag.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 24 May 2008 14:13:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/column-auto-sort-in-flex-2-datagrid/m-p/3875658#M931587</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-24T14:13:37Z</dc:date>
    </item>
    <item>
      <title>Re: Column auto sort in Flex 2 DataGrid</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/column-auto-sort-in-flex-2-datagrid/m-p/3875659#M931588</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i need to understand how you are managing the xml and how you are building the datagrid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;DataGrid that feeds from a XML generated on PHP&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;did you check that the xml is in proper order? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if you could post the piece of code where you received the xml and build the datagrid, it will be easier to crack.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Raja&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 25 May 2008 06:25:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/column-auto-sort-in-flex-2-datagrid/m-p/3875659#M931588</guid>
      <dc:creator>athavanraja</dc:creator>
      <dc:date>2008-05-25T06:25:02Z</dc:date>
    </item>
    <item>
      <title>Re: Column auto sort in Flex 2 DataGrid</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/column-auto-sort-in-flex-2-datagrid/m-p/3875660#M931589</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yup DataGrid auto sorts the columns alphabetically unless you specify their order, from the docs:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;An array of DataGridColumn objects, one for each column that can be displayed. If not explicitly set, the DataGrid control attempts to examine the first data provider item to determine the set of properties and display those properties in alphabetic order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;[DataGrid Flex 2 Documentation|http://livedocs.adobe.com/flex/2/langref/mx/controls/DataGrid.html#columns]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So... here is a nifty way to do it, that will preserve the order of the dataProvider that the datagrid is linked to ( which I believe is what you want it todo )  One side benefit is you can pass headerText in the XML it will also get mapped, FTW!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;
&amp;lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"&amp;gt;
	&amp;lt;mx:XMLList id="SAPData" xmlns=""&amp;gt;
		&amp;lt;row&amp;gt;&amp;lt;mandt headerText="Client"&amp;gt;000&amp;lt;/mandt&amp;gt;&amp;lt;name&amp;gt;Foo&amp;lt;/name&amp;gt;&amp;lt;surname&amp;gt;Bar&amp;lt;/surname&amp;gt;&amp;lt;age&amp;gt;66&amp;lt;/age&amp;gt;&amp;lt;/row&amp;gt;
		&amp;lt;row&amp;gt;&amp;lt;mandt&amp;gt;000&amp;lt;/mandt&amp;gt;&amp;lt;name&amp;gt;Dan&amp;lt;/name&amp;gt;&amp;lt;surname&amp;gt;Mcweeney&amp;lt;/surname&amp;gt;&amp;lt;age&amp;gt;28&amp;lt;/age&amp;gt;&amp;lt;/row&amp;gt;
	&amp;lt;/mx:XMLList&amp;gt;
	&amp;lt;mx:XMLList id="rowData" xmlns=""&amp;gt;
		&amp;lt;row mandt="000" name ="Foo" surname="Bar" age="66"/&amp;gt;
		&amp;lt;row mandt="000" name ="Dan" surname="McWee" age="28"/&amp;gt;
	&amp;lt;/mx:XMLList&amp;gt;
	&amp;lt;mx:Script&amp;gt;
		&amp;lt;![CDATA[
			import mx.controls.dataGridClasses.DataGridColumn;
			import mx.controls.DataGrid;
			private static const HeaderAttrib:String = "headerText";
			private function setupColumns(event:Event):void{
				var dg:DataGrid = event.currentTarget as DataGrid;
				if(dg == null)
					return;
				var columns:Array = dg.columns;
				columns.slice(0,columns.length);
				try{
					var xml:XML = dg.dataProvider[0];
				}
				catch(error:RangeError){
					return;
				}
				var col:DataGridColumn;
//  Normally data is returned nested as in the SAPData Example XMLList:  
				if(xml.attributes().length() == 0){
					for each(var item:XML in xml.children()){
						col = new DataGridColumn();
						col.dataField = item.name();
						if(item.attribute(HeaderAttrib).toString() == "")
							col.headerText = col.dataField;
						else
							col.headerText = item.attribute(HeaderAttrib);
						columns.push(col);
					}
				}				
				else{
// Don't think SAP returns data like this, but for completeness here is how it would work:
					for each(var attrib:XML in xml.attributes()){
						col = new DataGridColumn();
						col.dataField = "@" + attrib.name();
						col.headerText = attrib.name();
						columns.push(col);
					}		
				}
				dg.columns = columns;
			}
		
	
	&lt;DATAGRID dataprovider="{SAPData}" creationcomplete="setupColumns(event)"&gt;&lt;/DATAGRID&gt;	
	&lt;DATAGRID dataprovider="{rowData}" creationcomplete="setupColumns(event)" y="150"&gt;&lt;/DATAGRID&gt;
]]&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2008 20:16:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/column-auto-sort-in-flex-2-datagrid/m-p/3875660#M931589</guid>
      <dc:creator>former_member10945</dc:creator>
      <dc:date>2008-05-27T20:16:58Z</dc:date>
    </item>
  </channel>
</rss>

