<?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: Sorting date columns in a DataGrid</title>
	<atom:link href="http://blog.flexexamples.com/2007/08/12/sorting-date-columns-in-a-datagrid/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flexexamples.com/2007/08/12/sorting-date-columns-in-a-datagrid/</link>
	<description>Just a bunch of Adobe Flex Examples</description>
	<lastBuildDate>Sat, 11 Feb 2012 11:51:51 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Anonymous</title>
		<link>http://blog.flexexamples.com/2007/08/12/sorting-date-columns-in-a-datagrid/comment-page-1/#comment-10064</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Tue, 18 Oct 2011 19:39:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/08/12/sorting-date-columns-in-a-datagrid/#comment-10064</guid>
		<description>They&#039;re sorted alphabetically - a rather irritating choice for a default date sort.</description>
		<content:encoded><![CDATA[<p>They&#8217;re sorted alphabetically &#8211; a rather irritating choice for a default date sort.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sumeet</title>
		<link>http://blog.flexexamples.com/2007/08/12/sorting-date-columns-in-a-datagrid/comment-page-1/#comment-9305</link>
		<dc:creator>sumeet</dc:creator>
		<pubDate>Thu, 16 Jun 2011 07:50:54 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/08/12/sorting-date-columns-in-a-datagrid/#comment-9305</guid>
		<description>Hey Peter,


I tried your solution given to SM, however it does not work for me.

Note that my DG dataProvider is a xml of type 


  


I have tried to use the numericsort function but it does not sort correctly, also it stops working completely after first click on the header of creationData column.

Can you please suggest..

Thanks,</description>
		<content:encoded><![CDATA[<p>Hey Peter,</p>
<p>I tried your solution given to SM, however it does not work for me.</p>
<p>Note that my DG dataProvider is a xml of type </p>
<p>I have tried to use the numericsort function but it does not sort correctly, also it stops working completely after first click on the header of creationData column.</p>
<p>Can you please suggest..</p>
<p>Thanks,</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tahir Azeem Alvi</title>
		<link>http://blog.flexexamples.com/2007/08/12/sorting-date-columns-in-a-datagrid/comment-page-1/#comment-9171</link>
		<dc:creator>Tahir Azeem Alvi</dc:creator>
		<pubDate>Thu, 28 Apr 2011 16:13:15 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/08/12/sorting-date-columns-in-a-datagrid/#comment-9171</guid>
		<description>Hi Peter,

What is the event that gets fired when you click on a datagrid column to sort it?</description>
		<content:encoded><![CDATA[<p>Hi Peter,</p>
<p>What is the event that gets fired when you click on a datagrid column to sort it?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: izzy</title>
		<link>http://blog.flexexamples.com/2007/08/12/sorting-date-columns-in-a-datagrid/comment-page-1/#comment-8651</link>
		<dc:creator>izzy</dc:creator>
		<pubDate>Thu, 09 Dec 2010 21:21:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/08/12/sorting-date-columns-in-a-datagrid/#comment-8651</guid>
		<description>Is it possible to write a common component for sorting which can be used by multiple datagrids , also keeping in mind columns can be numeric , alphanumeric &amp; String Data type. If anything like this is possible , it will solve my problem

Thanks

Giri</description>
		<content:encoded><![CDATA[<p>Is it possible to write a common component for sorting which can be used by multiple datagrids , also keeping in mind columns can be numeric , alphanumeric &amp; String Data type. If anything like this is possible , it will solve my problem</p>
<p>Thanks</p>
<p>Giri</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nicolas Courjal</title>
		<link>http://blog.flexexamples.com/2007/08/12/sorting-date-columns-in-a-datagrid/comment-page-1/#comment-8441</link>
		<dc:creator>Nicolas Courjal</dc:creator>
		<pubDate>Thu, 14 Oct 2010 21:29:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/08/12/sorting-date-columns-in-a-datagrid/#comment-8441</guid>
		<description>Terrific. Exactly what I needed !</description>
		<content:encoded><![CDATA[<p>Terrific. Exactly what I needed !</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rafael Magana</title>
		<link>http://blog.flexexamples.com/2007/08/12/sorting-date-columns-in-a-datagrid/comment-page-1/#comment-8032</link>
		<dc:creator>Rafael Magana</dc:creator>
		<pubDate>Tue, 29 Jun 2010 14:57:50 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/08/12/sorting-date-columns-in-a-datagrid/#comment-8032</guid>
		<description>http://raflabs.com/blogs/silence-is-foo/2010/06/28/creating-a-common-sorting-function-for-a-datagrid-control-in-flex/

Sometimes I&#039;m in the situation where I need to use the same complex sorting function for several datagrids, here&#039;s my solution.</description>
		<content:encoded><![CDATA[<p><a href="http://raflabs.com/blogs/silence-is-foo/2010/06/28/creating-a-common-sorting-function-for-a-datagrid-control-in-flex/" rel="nofollow">http://raflabs.com/blogs/silence-is-foo/2010/06/28/creating-a-common-sorting-function-for-a-datagrid-control-in-flex/</a></p>
<p>Sometimes I&#8217;m in the situation where I need to use the same complex sorting function for several datagrids, here&#8217;s my solution.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Flexicious</title>
		<link>http://blog.flexexamples.com/2007/08/12/sorting-date-columns-in-a-datagrid/comment-page-1/#comment-7162</link>
		<dc:creator>Flexicious</dc:creator>
		<pubDate>Thu, 04 Mar 2010 02:07:47 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/08/12/sorting-date-columns-in-a-datagrid/#comment-7162</guid>
		<description>We actually have a grid that solves the issue of sorting/filtering by dates/numbers/booleans where the actual data is string and a intermediate conversion is required before the sort/filter operation. Please take a look at  http://www.flexicious.com.</description>
		<content:encoded><![CDATA[<p>We actually have a grid that solves the issue of sorting/filtering by dates/numbers/booleans where the actual data is string and a intermediate conversion is required before the sort/filter operation. Please take a look at  <a href="http://www.flexicious.com" rel="nofollow">http://www.flexicious.com</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Liscio</title>
		<link>http://blog.flexexamples.com/2007/08/12/sorting-date-columns-in-a-datagrid/comment-page-1/#comment-6843</link>
		<dc:creator>Michael Liscio</dc:creator>
		<pubDate>Mon, 25 Jan 2010 16:25:24 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/08/12/sorting-date-columns-in-a-datagrid/#comment-6843</guid>
		<description>This is a great solutio.  One small problem that I have found.  In a practical situation you could have rows in your datagrid that do not have a date filled in.  Idealy you would want these dates to appear first or last when you sort by your date collumn.  However I have found that this solution as is does not take that into consideration.  When you trace this out and look at both dates you will notice that if there is no value in the specific row you are looking at the date will show up as NaN.  This of course is expected obviously you can not convert a null value to a date.   If you keep tracing it out you will notice that depending on which way you are trying to sort accending or decending one of the two dates dateA, and dateB will always have a value.  if dateA = NaN you want to return -1 if dateB = NaN you want to return 1 otherwise let this function do its job.  So if you add the following lines to this function this is a perfect solution

if(dateA.time.toString() == &quot;NaN&quot;){
                	return -1
                }// end if
                
                else if(dateB.time.toString() == &quot;NaN&quot;){
                	return 1
                }// end if

obviosuly you will have to put the original return statement in the else case as follows

                      else{
                	return ObjectUtil.dateCompare(dateA, dateB);
                }// end else

Hope this helps

Thanks again for this solution</description>
		<content:encoded><![CDATA[<p>This is a great solutio.  One small problem that I have found.  In a practical situation you could have rows in your datagrid that do not have a date filled in.  Idealy you would want these dates to appear first or last when you sort by your date collumn.  However I have found that this solution as is does not take that into consideration.  When you trace this out and look at both dates you will notice that if there is no value in the specific row you are looking at the date will show up as NaN.  This of course is expected obviously you can not convert a null value to a date.   If you keep tracing it out you will notice that depending on which way you are trying to sort accending or decending one of the two dates dateA, and dateB will always have a value.  if dateA = NaN you want to return -1 if dateB = NaN you want to return 1 otherwise let this function do its job.  So if you add the following lines to this function this is a perfect solution</p>
<p>if(dateA.time.toString() == &#8220;NaN&#8221;){<br />
                	return -1<br />
                }// end if</p>
<p>                else if(dateB.time.toString() == &#8220;NaN&#8221;){<br />
                	return 1<br />
                }// end if</p>
<p>obviosuly you will have to put the original return statement in the else case as follows</p>
<p>                      else{<br />
                	return ObjectUtil.dateCompare(dateA, dateB);<br />
                }// end else</p>
<p>Hope this helps</p>
<p>Thanks again for this solution</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter deHaan</title>
		<link>http://blog.flexexamples.com/2007/08/12/sorting-date-columns-in-a-datagrid/comment-page-1/#comment-6714</link>
		<dc:creator>Peter deHaan</dc:creator>
		<pubDate>Sat, 02 Jan 2010 16:03:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/08/12/sorting-date-columns-in-a-datagrid/#comment-6714</guid>
		<description>@DAvid,

See jalal&#039;s suggestion above: http://blog.flexexamples.com/2007/08/12/sorting-date-columns-in-a-datagrid/#comment-563

Peter</description>
		<content:encoded><![CDATA[<p>@DAvid,</p>
<p>See jalal&#8217;s suggestion above: <a href="http://blog.flexexamples.com/2007/08/12/sorting-date-columns-in-a-datagrid/#comment-563" rel="nofollow">http://blog.flexexamples.com/2007/08/12/sorting-date-columns-in-a-datagrid/#comment-563</a></p>
<p>Peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DAvid</title>
		<link>http://blog.flexexamples.com/2007/08/12/sorting-date-columns-in-a-datagrid/comment-page-1/#comment-6712</link>
		<dc:creator>DAvid</dc:creator>
		<pubDate>Sat, 02 Jan 2010 11:18:20 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/08/12/sorting-date-columns-in-a-datagrid/#comment-6712</guid>
		<description>Hi, 

if ever the date i want to display is of format: &quot;DD/MM/YYYY&quot;.

How does that one goes?

Thanks in advance ...

David</description>
		<content:encoded><![CDATA[<p>Hi, </p>
<p>if ever the date i want to display is of format: &#8220;DD/MM/YYYY&#8221;.</p>
<p>How does that one goes?</p>
<p>Thanks in advance &#8230;</p>
<p>David</p>
]]></content:encoded>
	</item>
</channel>
</rss>

