<?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: Default Sorting for a Flex DataGrid</title>
	<atom:link href="http://www.bealearts.co.uk/blog/2007/06/15/default-sorting-for-a-flex-datagrid/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bealearts.co.uk/blog/2007/06/15/default-sorting-for-a-flex-datagrid/</link>
	<description>BealeARTS - Information Ingenuity</description>
	<lastBuildDate>Thu, 29 Jul 2010 03:23:39 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Jon</title>
		<link>http://www.bealearts.co.uk/blog/2007/06/15/default-sorting-for-a-flex-datagrid/comment-page-1/#comment-3081</link>
		<dc:creator>Jon</dc:creator>
		<pubDate>Thu, 29 Jul 2010 03:23:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.bealearts.co.uk/blog/2007/06/15/default-sorting-for-a-flex-datagrid/#comment-3081</guid>
		<description>This neat hack is totally unnecessary if you use an instance of ListCollectionView as your dataProvider because you can accomplish this by setting the sort property of your collection as shown below. Your suggestion would also reset the sort column if/when data is reloaded from the server.  Thus you should create your collection and set the default sort field during initialization, then populate your collection anytime data is loaded from an external source, which will preserve the user&#039;s chosen sort columns when data is reloaded.

However, I&#039;ve found that if you have to set a custom sort function, then the DataGrid and AdvancedDataGrid doesn&#039;t show the ascending/descending marker by default even though the data is properly sorted.  I tried your suggestion to see if it would resolve my issue, but unfortunately it does not work either.

[code]

import mx.collections.Sort;
import mx.collections.SortField;
import mx.collections.XMLListCollection;

private accounts:XMLListCollection;
private function init():void {	
   accounts = new XMLListCollection();
   accounts.sort = new Sort();
   accounts.sort.fields = [new SortField(&quot;name&quot;, true, false, false)];
   accounts.refresh();
}

[/code]

If you want to try an awesome data grid, go to http://flexicious.com/Home/Demo.</description>
		<content:encoded><![CDATA[<p>This neat hack is totally unnecessary if you use an instance of ListCollectionView as your dataProvider because you can accomplish this by setting the sort property of your collection as shown below. Your suggestion would also reset the sort column if/when data is reloaded from the server.  Thus you should create your collection and set the default sort field during initialization, then populate your collection anytime data is loaded from an external source, which will preserve the user&#8217;s chosen sort columns when data is reloaded.</p>
<p>However, I&#8217;ve found that if you have to set a custom sort function, then the DataGrid and AdvancedDataGrid doesn&#8217;t show the ascending/descending marker by default even though the data is properly sorted.  I tried your suggestion to see if it would resolve my issue, but unfortunately it does not work either.</p>
<p>[code]</p>
<p>import mx.collections.Sort;<br />
import mx.collections.SortField;<br />
import mx.collections.XMLListCollection;</p>
<p>private accounts:XMLListCollection;<br />
private function init():void {<br />
   accounts = new XMLListCollection();<br />
   accounts.sort = new Sort();<br />
   accounts.sort.fields = [new SortField("name", true, false, false)];<br />
   accounts.refresh();<br />
}</p>
<p>[/code]</p>
<p>If you want to try an awesome data grid, go to <a href="http://flexicious.com/Home/Demo" rel="nofollow">http://flexicious.com/Home/Demo</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris</title>
		<link>http://www.bealearts.co.uk/blog/2007/06/15/default-sorting-for-a-flex-datagrid/comment-page-1/#comment-232</link>
		<dc:creator>Chris</dc:creator>
		<pubDate>Wed, 21 Jul 2010 20:18:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.bealearts.co.uk/blog/2007/06/15/default-sorting-for-a-flex-datagrid/#comment-232</guid>
		<description>Thank you so much! That&#039;s a perfect little snippet I pasted right into my code.</description>
		<content:encoded><![CDATA[<p>Thank you so much! That&#8217;s a perfect little snippet I pasted right into my code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: adeb</title>
		<link>http://www.bealearts.co.uk/blog/2007/06/15/default-sorting-for-a-flex-datagrid/comment-page-1/#comment-209</link>
		<dc:creator>adeb</dc:creator>
		<pubDate>Tue, 13 Jul 2010 11:13:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.bealearts.co.uk/blog/2007/06/15/default-sorting-for-a-flex-datagrid/#comment-209</guid>
		<description>Thanks a lot</description>
		<content:encoded><![CDATA[<p>Thanks a lot</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric Heimburg</title>
		<link>http://www.bealearts.co.uk/blog/2007/06/15/default-sorting-for-a-flex-datagrid/comment-page-1/#comment-202</link>
		<dc:creator>Eric Heimburg</dc:creator>
		<pubDate>Mon, 05 Jul 2010 03:54:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.bealearts.co.uk/blog/2007/06/15/default-sorting-for-a-flex-datagrid/#comment-202</guid>
		<description>Just wanted to say thanks for this, too. Bizarre that this is not a built-in feature, though...</description>
		<content:encoded><![CDATA[<p>Just wanted to say thanks for this, too. Bizarre that this is not a built-in feature, though&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Lira</title>
		<link>http://www.bealearts.co.uk/blog/2007/06/15/default-sorting-for-a-flex-datagrid/comment-page-1/#comment-191</link>
		<dc:creator>David Lira</dc:creator>
		<pubDate>Tue, 22 Jun 2010 12:04:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.bealearts.co.uk/blog/2007/06/15/default-sorting-for-a-flex-datagrid/#comment-191</guid>
		<description>You can define the first sort like ASC or DESC setting the propertie sortDescending in datagrid. True for descending or false for ascending. I think that is a better solution than dispatch two events.</description>
		<content:encoded><![CDATA[<p>You can define the first sort like ASC or DESC setting the propertie sortDescending in datagrid. True for descending or false for ascending. I think that is a better solution than dispatch two events.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pratik</title>
		<link>http://www.bealearts.co.uk/blog/2007/06/15/default-sorting-for-a-flex-datagrid/comment-page-1/#comment-175</link>
		<dc:creator>Pratik</dc:creator>
		<pubDate>Thu, 20 May 2010 15:21:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.bealearts.co.uk/blog/2007/06/15/default-sorting-for-a-flex-datagrid/#comment-175</guid>
		<description>Thanks....it really helped n what a cool way to do that !</description>
		<content:encoded><![CDATA[<p>Thanks&#8230;.it really helped n what a cool way to do that !</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: links for 2010-04-21 &#124; andy.edmonds.be</title>
		<link>http://www.bealearts.co.uk/blog/2007/06/15/default-sorting-for-a-flex-datagrid/comment-page-1/#comment-174</link>
		<dc:creator>links for 2010-04-21 &#124; andy.edmonds.be</dc:creator>
		<pubDate>Thu, 22 Apr 2010 00:33:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.bealearts.co.uk/blog/2007/06/15/default-sorting-for-a-flex-datagrid/#comment-174</guid>
		<description>[...] Default Sorting for a Flex DataGrid &#124; BealeARTS (tags: flex datagrid sorting automatic) [...]</description>
		<content:encoded><![CDATA[<p>[...] Default Sorting for a Flex DataGrid | BealeARTS (tags: flex datagrid sorting automatic) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rich Sadowsky</title>
		<link>http://www.bealearts.co.uk/blog/2007/06/15/default-sorting-for-a-flex-datagrid/comment-page-1/#comment-129</link>
		<dc:creator>Rich Sadowsky</dc:creator>
		<pubDate>Fri, 12 Feb 2010 22:19:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.bealearts.co.uk/blog/2007/06/15/default-sorting-for-a-flex-datagrid/#comment-129</guid>
		<description>Let me throw my thanks into the mix. I used the dgSort function in the comments above with sortDescending and it did exactly what I needed. That said, it seems like this should be an inherent property of the DataGrid to allow you to specify a column to use for the initial sort. As we can see from these functions it is not hard to accomplish and it seems like a very common use case. Adobe Flex Components team, are you listening?</description>
		<content:encoded><![CDATA[<p>Let me throw my thanks into the mix. I used the dgSort function in the comments above with sortDescending and it did exactly what I needed. That said, it seems like this should be an inherent property of the DataGrid to allow you to specify a column to use for the initial sort. As we can see from these functions it is not hard to accomplish and it seems like a very common use case. Adobe Flex Components team, are you listening?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Toggi</title>
		<link>http://www.bealearts.co.uk/blog/2007/06/15/default-sorting-for-a-flex-datagrid/comment-page-1/#comment-123</link>
		<dc:creator>Toggi</dc:creator>
		<pubDate>Mon, 01 Feb 2010 23:45:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.bealearts.co.uk/blog/2007/06/15/default-sorting-for-a-flex-datagrid/#comment-123</guid>
		<description>Thanks for the idea of dispatching the event. I used it with the trick of descending the column and it works as I wanted.</description>
		<content:encoded><![CDATA[<p>Thanks for the idea of dispatching the event. I used it with the trick of descending the column and it works as I wanted.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mynam</title>
		<link>http://www.bealearts.co.uk/blog/2007/06/15/default-sorting-for-a-flex-datagrid/comment-page-1/#comment-117</link>
		<dc:creator>Mynam</dc:creator>
		<pubDate>Wed, 20 Jan 2010 18:52:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.bealearts.co.uk/blog/2007/06/15/default-sorting-for-a-flex-datagrid/#comment-117</guid>
		<description>Nice tip.. Thanks tons for all the time you have saved.</description>
		<content:encoded><![CDATA[<p>Nice tip.. Thanks tons for all the time you have saved.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 1.379 seconds -->
