<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Displaying the sort arrow in a Flex DataGrid control without having to click a column</title>
	<atom:link href="http://blog.flexexamples.com/2008/02/28/displaying-the-sort-arrow-in-a-flex-datagrid-control-without-having-to-click-a-column/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flexexamples.com/2008/02/28/displaying-the-sort-arrow-in-a-flex-datagrid-control-without-having-to-click-a-column/</link>
	<description>Just a bunch of Adobe Flex Examples</description>
	<lastBuildDate>Sun, 12 Feb 2012 19:26:49 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Chiheb Ben jemia</title>
		<link>http://blog.flexexamples.com/2008/02/28/displaying-the-sort-arrow-in-a-flex-datagrid-control-without-having-to-click-a-column/comment-page-1/#comment-10343</link>
		<dc:creator>Chiheb Ben jemia</dc:creator>
		<pubDate>Mon, 30 Jan 2012 17:01:54 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/02/28/displaying-the-sort-arrow-in-a-flex-datagrid-control-without-having-to-click-a-column/#comment-10343</guid>
		<description>
			
				
					
						
						
					
				
					
		
			
				
						
						
						
						
				
			
			
				
			
			
		
		</description>
		<content:encoded><![CDATA[]]></content:encoded>
	</item>
	<item>
		<title>By: Chiheb Ben jemia</title>
		<link>http://blog.flexexamples.com/2008/02/28/displaying-the-sort-arrow-in-a-flex-datagrid-control-without-having-to-click-a-column/comment-page-1/#comment-10342</link>
		<dc:creator>Chiheb Ben jemia</dc:creator>
		<pubDate>Mon, 30 Jan 2012 17:01:06 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/02/28/displaying-the-sort-arrow-in-a-flex-datagrid-control-without-having-to-click-a-column/#comment-10342</guid>
		<description>&lt;a href=&quot;&quot; title=&quot;&quot; rel=&quot;nofollow&quot;&gt; &lt;abbr title=&quot;&quot;&gt; &lt;acronym title=&quot;&quot;&gt; &lt;b&gt; &lt;blockquote cite=&quot;&quot;&gt; &lt;cite&gt; &lt;code&gt; &lt;del datetime=&quot;&quot;&gt; &lt;em&gt; &lt;i&gt; &lt;q cite=&quot;&quot;&gt; &lt;strike&gt; &lt;strong&gt; &lt;pre lang=&quot;&quot; line=&quot;&quot; escaped=&quot;&quot;&gt;

ok there is the other part of the code...!


			
				
					
						
						
					
				
					
		
			
				
						
						
						
						
				
			
			
				
			
			
		
		</description>
		<content:encoded><![CDATA[<p><a href="" title="" rel="nofollow"> <abbr title=""> <acronym title=""> <b><br />
<blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
<pre lang="" line="" escaped="">

ok there is the other part of the code...!</pre>
<p></strong></strike></q></i></em></del></code></cite></p></blockquote>
<p></b></acronym></abbr></a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chiheb Ben jemia</title>
		<link>http://blog.flexexamples.com/2008/02/28/displaying-the-sort-arrow-in-a-flex-datagrid-control-without-having-to-click-a-column/comment-page-1/#comment-10341</link>
		<dc:creator>Chiheb Ben jemia</dc:creator>
		<pubDate>Mon, 30 Jan 2012 16:59:18 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/02/28/displaying-the-sort-arrow-in-a-flex-datagrid-control-without-having-to-click-a-column/#comment-10341</guid>
		<description>hello peter
in my example I have two datagrids, the first &quot;cltdgg&quot; is sorting and arrow appears in the columns. While nothing in the second. Is there a link to the AsyncListView?
Thank you for your help :)

Flex4, FlashBuilder 4.5 for Php

here is the code exemple :

private var dataProvider : ArrayCollection = new ArrayCollection(
				
				[{price:&quot;20&quot;,location:&quot;india&quot;},					
					{price:&quot;5&quot;,location:&quot;india&quot;},			
					{price:&quot;40&quot;,location:&quot;india&quot;},
					{price:&quot;20&quot;,location:&quot;germeny&quot;},
					{price:&quot;20&quot;,location:&quot;spain&quot;},
					{price:&quot;10&quot;,location:&quot;usa&quot;},
					{price:&quot;30&quot;,location:&quot;Italy&quot;}]);
			

protected function cltDg_creationCompleteHandler(event:FlexEvent):void {
				getClientsResult.token = serviceClients.getclients();
			}	


			
				
					
						
						
					
				
					
		
			
				
						
						
						
						
				
			
			
				
			
			
		
		</description>
		<content:encoded><![CDATA[<p>hello peter<br />
in my example I have two datagrids, the first &#8220;cltdgg&#8221; is sorting and arrow appears in the columns. While nothing in the second. Is there a link to the AsyncListView?<br />
Thank you for your help :)</p>
<p>Flex4, FlashBuilder 4.5 for Php</p>
<p>here is the code exemple :</p>
<p>private var dataProvider : ArrayCollection = new ArrayCollection(</p>
<p>				[{price:"20",location:"india"},<br />
					{price:"5",location:"india"},<br />
					{price:"40",location:"india"},<br />
					{price:"20",location:"germeny"},<br />
					{price:"20",location:"spain"},<br />
					{price:"10",location:"usa"},<br />
					{price:"30",location:"Italy"}]);</p>
<p>protected function cltDg_creationCompleteHandler(event:FlexEvent):void {<br />
				getClientsResult.token = serviceClients.getclients();<br />
			}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pete</title>
		<link>http://blog.flexexamples.com/2008/02/28/displaying-the-sort-arrow-in-a-flex-datagrid-control-without-having-to-click-a-column/comment-page-1/#comment-10042</link>
		<dc:creator>Pete</dc:creator>
		<pubDate>Wed, 12 Oct 2011 23:43:37 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/02/28/displaying-the-sort-arrow-in-a-flex-datagrid-control-without-having-to-click-a-column/#comment-10042</guid>
		<description>Sort and SortField are flawed in the standard Adobe grid. For one thing, they do not respect any custom SortCompareFunctions you may have set on the grid, and while the arrows will appear if you have ONE field set, it will not appear if you have two set.

I found that most of the requirements in the original posting can be better addressed without extending any classes simply by dispatching a headerRelease Event.

This actually works FAR better than using sortFields because not only does it cause the arrow to appear correctly, it will also respect any custom sortCompareFunction/s on the DataGridColumns, which the basic Sort/SortField method does not do.
&lt;code&gt;

			/**
			 * Whenever data or external sort criteria change, call this method. It will
			 * resort the pending list by simulating a mouseclick (headRelease event), triggering
			 * a sortColumn() call.
			 * 
			 * The normal method of sorting (creating a SortField) does not respect the sortCompareFunction
			 * rules and does not pop up the little arrow on the column(s) being sorted; this does.
			 * */
			private function setDefaultPendingSort():void {
				

				// Adobe&#039;s &quot;textbook&quot; way to sort columns doesn&#039;t respect custom column sorting, 
				// and will not display the arrow when sorting on multiple columns:
				//model.sampleList.sort = new Sort();
				//model.sampleList.sort.fields = [new SortField(&quot;emp_name&quot;, true,false,true), new SortField(&quot;emp_id&quot;,true,false,true)];
				//model.sampleList.refresh();
				
				// The MUCH better way simulates a mouseclick on the header...
				
				var defaultColumn:String = &quot;emp_name&quot;; //&quot;accessionNum&quot;;
				var col:DataGridColumn = getColumnByDataField(dgPendingSamples, defaultColumn);
				col.sortDescending = false;  
				
				var dgEvent:DataGridEvent = new DataGridEvent(&quot;headerRelease&quot;);
				dgEvent.dataField = defaultColumn;
				dgEvent.columnIndex = getColumnIndexByDataField(dgPendingSamples, defaultColumn);
				dgEvent.rowIndex = -1;
				dgPendingSamples.dispatchEvent(dgEvent);
				
				
			}

	/** 
			 * Returns the column based on the column&#039;s data field. Returns the first column found that
			 * uses the specified dataField, or -1 if none found.
			 * */
			private function getColumnIndexByDataField(dg:DataGrid, dfld:String):int {
				for (var i:uint = 0; i &lt; dg.columnCount; i++) {
					var col:DataGridColumn = dg.columns[i];
					if(col.dataField == dfld) {
						return i;
					}
				}
				return -1;
			}

			/** 
			 * Returns the column based on the header text, allowing 
			 * columns to be rearranged without fucking up column dependencies.
			 * Returns null if none match.
			 * */
			private function getColumnByDataField(dg:DataGrid, dfld:String):DataGridColumn {
				for (var i:uint = 0; i &lt; dg.columnCount; i++) {
					var col:DataGridColumn = dg.columns[i];
					if(col.dataField == dfld) {
						return col;
					}
				}
				return null;
			}

&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Sort and SortField are flawed in the standard Adobe grid. For one thing, they do not respect any custom SortCompareFunctions you may have set on the grid, and while the arrows will appear if you have ONE field set, it will not appear if you have two set.</p>
<p>I found that most of the requirements in the original posting can be better addressed without extending any classes simply by dispatching a headerRelease Event.</p>
<p>This actually works FAR better than using sortFields because not only does it cause the arrow to appear correctly, it will also respect any custom sortCompareFunction/s on the DataGridColumns, which the basic Sort/SortField method does not do.<br />
<code></p>
<p>			/**<br />
			 * Whenever data or external sort criteria change, call this method. It will<br />
			 * resort the pending list by simulating a mouseclick (headRelease event), triggering<br />
			 * a sortColumn() call.<br />
			 *<br />
			 * The normal method of sorting (creating a SortField) does not respect the sortCompareFunction<br />
			 * rules and does not pop up the little arrow on the column(s) being sorted; this does.<br />
			 * */<br />
			private function setDefaultPendingSort():void {</p>
<p>				// Adobe's "textbook" way to sort columns doesn't respect custom column sorting,<br />
				// and will not display the arrow when sorting on multiple columns:<br />
				//model.sampleList.sort = new Sort();<br />
				//model.sampleList.sort.fields = [new SortField("emp_name", true,false,true), new SortField("emp_id",true,false,true)];<br />
				//model.sampleList.refresh();</p>
<p>				// The MUCH better way simulates a mouseclick on the header...</p>
<p>				var defaultColumn:String = "emp_name"; //"accessionNum";<br />
				var col:DataGridColumn = getColumnByDataField(dgPendingSamples, defaultColumn);<br />
				col.sortDescending = false;  </p>
<p>				var dgEvent:DataGridEvent = new DataGridEvent("headerRelease");<br />
				dgEvent.dataField = defaultColumn;<br />
				dgEvent.columnIndex = getColumnIndexByDataField(dgPendingSamples, defaultColumn);<br />
				dgEvent.rowIndex = -1;<br />
				dgPendingSamples.dispatchEvent(dgEvent);</p>
<p>			}</p>
<p>	/**<br />
			 * Returns the column based on the column's data field. Returns the first column found that<br />
			 * uses the specified dataField, or -1 if none found.<br />
			 * */<br />
			private function getColumnIndexByDataField(dg:DataGrid, dfld:String):int {<br />
				for (var i:uint = 0; i &lt; dg.columnCount; i++) {<br />
					var col:DataGridColumn = dg.columns[i];<br />
					if(col.dataField == dfld) {<br />
						return i;<br />
					}<br />
				}<br />
				return -1;<br />
			}</p>
<p>			/**<br />
			 * Returns the column based on the header text, allowing<br />
			 * columns to be rearranged without fucking up column dependencies.<br />
			 * Returns null if none match.<br />
			 * */<br />
			private function getColumnByDataField(dg:DataGrid, dfld:String):DataGridColumn {<br />
				for (var i:uint = 0; i &lt; dg.columnCount; i++) {<br />
					var col:DataGridColumn = dg.columns[i];<br />
					if(col.dataField == dfld) {<br />
						return col;<br />
					}<br />
				}<br />
				return null;<br />
			}</p>
<p></code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sampath</title>
		<link>http://blog.flexexamples.com/2008/02/28/displaying-the-sort-arrow-in-a-flex-datagrid-control-without-having-to-click-a-column/comment-page-1/#comment-9347</link>
		<dc:creator>sampath</dc:creator>
		<pubDate>Wed, 29 Jun 2011 07:24:15 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/02/28/displaying-the-sort-arrow-in-a-flex-datagrid-control-without-having-to-click-a-column/#comment-9347</guid>
		<description>Hi All,
I am working on sortarrow skin for past 4 days and its really frustrating.
I am trying to show a disabled sort arrow skin on all columns when datagrid loads initially.When a user clicks on particullar column the disabled skin should be removed and changed to a different skin.I extended grid and override updatelist,headerrelease but nothing worked as planned.I am really hopping that someone can help me with it.I am trying to achieve this for past few days but had many prioblems.

Thanks ........</description>
		<content:encoded><![CDATA[<p>Hi All,<br />
I am working on sortarrow skin for past 4 days and its really frustrating.<br />
I am trying to show a disabled sort arrow skin on all columns when datagrid loads initially.When a user clicks on particullar column the disabled skin should be removed and changed to a different skin.I extended grid and override updatelist,headerrelease but nothing worked as planned.I am really hopping that someone can help me with it.I am trying to achieve this for past few days but had many prioblems.</p>
<p>Thanks &#8230;&#8230;..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: felipe molina</title>
		<link>http://blog.flexexamples.com/2008/02/28/displaying-the-sort-arrow-in-a-flex-datagrid-control-without-having-to-click-a-column/comment-page-1/#comment-9217</link>
		<dc:creator>felipe molina</dc:creator>
		<pubDate>Thu, 12 May 2011 16:00:41 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/02/28/displaying-the-sort-arrow-in-a-flex-datagrid-control-without-having-to-click-a-column/#comment-9217</guid>
		<description>solved: arrColl.lastResult.sort.fields = [new SortField(&quot;idx&quot;, true)];. Easy XD.</description>
		<content:encoded><![CDATA[<p>solved: arrColl.lastResult.sort.fields = [new SortField("idx", true)];. Easy XD.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: felipe molina</title>
		<link>http://blog.flexexamples.com/2008/02/28/displaying-the-sort-arrow-in-a-flex-datagrid-control-without-having-to-click-a-column/comment-page-1/#comment-9216</link>
		<dc:creator>felipe molina</dc:creator>
		<pubDate>Thu, 12 May 2011 15:54:51 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/02/28/displaying-the-sort-arrow-in-a-flex-datagrid-control-without-having-to-click-a-column/#comment-9216</guid>
		<description>sorry about my english... This code has helped me, but i can&#039;t get sort data from down to up, i&#039;m using flash builder 4 and sdk 4. Any help would be very appreciated.</description>
		<content:encoded><![CDATA[<p>sorry about my english&#8230; This code has helped me, but i can&#8217;t get sort data from down to up, i&#8217;m using flash builder 4 and sdk 4. Any help would be very appreciated.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter deHaan</title>
		<link>http://blog.flexexamples.com/2008/02/28/displaying-the-sort-arrow-in-a-flex-datagrid-control-without-having-to-click-a-column/comment-page-1/#comment-8371</link>
		<dc:creator>Peter deHaan</dc:creator>
		<pubDate>Wed, 29 Sep 2010 00:34:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/02/28/displaying-the-sort-arrow-in-a-flex-datagrid-control-without-having-to-click-a-column/#comment-8371</guid>
		<description>@Paul,

Not sure where your sorting code is, but I&#039;d guess that you&#039;re losing the sort arrow because you are resetting the data provider each time the header is clicked.

Peter</description>
		<content:encoded><![CDATA[<p>@Paul,</p>
<p>Not sure where your sorting code is, but I&#8217;d guess that you&#8217;re losing the sort arrow because you are resetting the data provider each time the header is clicked.</p>
<p>Peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul</title>
		<link>http://blog.flexexamples.com/2008/02/28/displaying-the-sort-arrow-in-a-flex-datagrid-control-without-having-to-click-a-column/comment-page-1/#comment-8369</link>
		<dc:creator>Paul</dc:creator>
		<pubDate>Tue, 28 Sep 2010 20:14:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/02/28/displaying-the-sort-arrow-in-a-flex-datagrid-control-without-having-to-click-a-column/#comment-8369</guid>
		<description>Peter i used the headerrelease function to sort the datagrid, the code is:

arrcoll is my dataprovider, but when sort the ArrayCollection lose the arrow ASC/DSC.

private var clickedColumn:String;
    private function dataGrid_headerRelease(evt:DataGridEvent):void {
    var dgrid:DataGrid = DataGrid(evt.currentTarget);
    var column:DataGridColumn = dgrid.columns[evt.columnIndex];
    var tempField:Object = column.dataField;
    clickedColumn = tempField.toString();
    dgPacientes.dataProvider = arrCol;
} 

i need help.


bye.</description>
		<content:encoded><![CDATA[<p>Peter i used the headerrelease function to sort the datagrid, the code is:</p>
<p>arrcoll is my dataprovider, but when sort the ArrayCollection lose the arrow ASC/DSC.</p>
<p>private var clickedColumn:String;<br />
    private function dataGrid_headerRelease(evt:DataGridEvent):void {<br />
    var dgrid:DataGrid = DataGrid(evt.currentTarget);<br />
    var column:DataGridColumn = dgrid.columns[evt.columnIndex];<br />
    var tempField:Object = column.dataField;<br />
    clickedColumn = tempField.toString();<br />
    dgPacientes.dataProvider = arrCol;<br />
} </p>
<p>i need help.</p>
<p>bye.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Geert</title>
		<link>http://blog.flexexamples.com/2008/02/28/displaying-the-sort-arrow-in-a-flex-datagrid-control-without-having-to-click-a-column/comment-page-1/#comment-8112</link>
		<dc:creator>Geert</dc:creator>
		<pubDate>Thu, 15 Jul 2010 13:15:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/02/28/displaying-the-sort-arrow-in-a-flex-datagrid-control-without-having-to-click-a-column/#comment-8112</guid>
		<description>Very nice how this person solved it:
http://interactive-squared.co.uk/index.php/2009/10/12/programmatically-getting-datagrid-to-sort/</description>
		<content:encoded><![CDATA[<p>Very nice how this person solved it:<br />
<a href="http://interactive-squared.co.uk/index.php/2009/10/12/programmatically-getting-datagrid-to-sort/" rel="nofollow">http://interactive-squared.co.uk/index.php/2009/10/12/programmatically-getting-datagrid-to-sort/</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>

