<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2.1" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Sorting and filtering data in an XMLListCollection</title>
	<link>http://blog.flexexamples.com/2007/08/22/sorting-and-filtering-data-in-an-xmllistcollection/</link>
	<description>A bunch of examples for Adobe Flex and ActionScript</description>
	<pubDate>Tue, 06 Jan 2009 00:51:09 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.1</generator>

	<item>
		<title>By: Geoff</title>
		<link>http://blog.flexexamples.com/2007/08/22/sorting-and-filtering-data-in-an-xmllistcollection/#comment-15987</link>
		<author>Geoff</author>
		<pubDate>Fri, 03 Oct 2008 15:08:57 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/08/22/sorting-and-filtering-data-in-an-xmllistcollection/#comment-15987</guid>
		<description>Another great example.  Many thanks!</description>
		<content:encoded><![CDATA[<p>Another great example.  Many thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peterd</title>
		<link>http://blog.flexexamples.com/2007/08/22/sorting-and-filtering-data-in-an-xmllistcollection/#comment-11547</link>
		<author>peterd</author>
		<pubDate>Thu, 10 Apr 2008 04:14:58 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/08/22/sorting-and-filtering-data-in-an-xmllistcollection/#comment-11547</guid>
		<description>northwebs.net/Sjoerd,

Does this answer your question at all? &lt;a href="http://blog.flexexamples.com/2008/04/09/creating-a-custom-sort-on-a-datagrid-control-in-flex/" rel="nofollow"&gt;&lt;u&gt;"Creating a custom sort on a DataGrid control in Flex"&lt;/u&gt;&lt;/a&gt;

Peter</description>
		<content:encoded><![CDATA[<p>northwebs.net/Sjoerd,</p>
<p>Does this answer your question at all? <a href="http://blog.flexexamples.com/2008/04/09/creating-a-custom-sort-on-a-datagrid-control-in-flex/" rel="nofollow"><u>&#8220;Creating a custom sort on a DataGrid control in Flex&#8221;</u></a></p>
<p>Peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: northwebs.net</title>
		<link>http://blog.flexexamples.com/2007/08/22/sorting-and-filtering-data-in-an-xmllistcollection/#comment-11471</link>
		<author>northwebs.net</author>
		<pubDate>Wed, 09 Apr 2008 16:33:20 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/08/22/sorting-and-filtering-data-in-an-xmllistcollection/#comment-11471</guid>
		<description>hello Peter :)

about sorting tree we can use @name for Sjoerd case?</description>
		<content:encoded><![CDATA[<p>hello Peter :)</p>
<p>about sorting tree we can use @name for Sjoerd case?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shawn</title>
		<link>http://blog.flexexamples.com/2007/08/22/sorting-and-filtering-data-in-an-xmllistcollection/#comment-6178</link>
		<author>Shawn</author>
		<pubDate>Thu, 17 Jan 2008 14:28:05 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/08/22/sorting-and-filtering-data-in-an-xmllistcollection/#comment-6178</guid>
		<description>I have been trying for days to get the XMLListCollection to filter and sort.

I am receiving this document from a web service in e4x and initialize my xmllistcollection as follows:


My xml looks like:


   
     
   



Where member 3 is a child of member 2 and member 2 is a child of member 1.  I have tried to apply the filter and the sort and nothing happens.  Here are my methods:
&lt;pre class="code"&gt;
protected function sortItems():void
{
	var treeSort:Sort = new Sort();
				
	treeSort.fields = [new SortField("@id", true)];
	dataSource_Tree.sort = treeSort;
	dataSource_Tree.refresh();
}
protected function filterByColor():void
{
	dataSource_Tree.filterFunction = colorFilter;  //dataSource_Tree is XMLListCollection
	dataSource_LOSTree.refresh();
}
			
protected function colorFilter(item:Object):Boolean   // User selects a color by textbox
{			
	return item.@color == 'blue';
}
&lt;/pre&gt;

I have traced several times and each time nothing happens to the xml.  no filter, no sort... nothing.  According to the Flex documentation, filterfunctions are supposed to traverse the entire xml document node by node, but when i trace the passed in item on the colorFilter I get the entire xml document.  And the colorFilter method only gets called once (with the full xml) instead of item by item.

Is there a different way I need to filter a tree with nested nodes?</description>
		<content:encoded><![CDATA[<p>I have been trying for days to get the XMLListCollection to filter and sort.</p>
<p>I am receiving this document from a web service in e4x and initialize my xmllistcollection as follows:</p>
<p>My xml looks like:</p>
<p>Where member 3 is a child of member 2 and member 2 is a child of member 1.  I have tried to apply the filter and the sort and nothing happens.  Here are my methods:</p>
<pre class="code">
protected function sortItems():void
{
	var treeSort:Sort = new Sort();

	treeSort.fields = [new SortField("@id", true)];
	dataSource_Tree.sort = treeSort;
	dataSource_Tree.refresh();
}
protected function filterByColor():void
{
	dataSource_Tree.filterFunction = colorFilter;  //dataSource_Tree is XMLListCollection
	dataSource_LOSTree.refresh();
}

protected function colorFilter(item:Object):Boolean   // User selects a color by textbox
{
	return <a href="mailto:item.@color">item.@color</a> == &#8216;blue&#8217;;
}
</pre>
<p>I have traced several times and each time nothing happens to the xml.  no filter, no sort&#8230; nothing.  According to the Flex documentation, filterfunctions are supposed to traverse the entire xml document node by node, but when i trace the passed in item on the colorFilter I get the entire xml document.  And the colorFilter method only gets called once (with the full xml) instead of item by item.</p>
<p>Is there a different way I need to filter a tree with nested nodes?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peterd</title>
		<link>http://blog.flexexamples.com/2007/08/22/sorting-and-filtering-data-in-an-xmllistcollection/#comment-2961</link>
		<author>peterd</author>
		<pubDate>Thu, 27 Sep 2007 06:42:09 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/08/22/sorting-and-filtering-data-in-an-xmllistcollection/#comment-2961</guid>
		<description>Sjoerd,

Is that the entire XML that you want to sort, or is there more?

Peter</description>
		<content:encoded><![CDATA[<p>Sjoerd,</p>
<p>Is that the entire XML that you want to sort, or is there more?</p>
<p>Peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sjoerd</title>
		<link>http://blog.flexexamples.com/2007/08/22/sorting-and-filtering-data-in-an-xmllistcollection/#comment-2922</link>
		<author>Sjoerd</author>
		<pubDate>Wed, 26 Sep 2007 09:10:55 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/08/22/sorting-and-filtering-data-in-an-xmllistcollection/#comment-2922</guid>
		<description>What about a XML that looks like this:

&lt;pre class="code"&gt;
&#60;test name="groupname"&#62;
    &#60;test2 name="old"&#62;bla1data&#60;/test2&#62;
    &#60;test3 name="new"&#62;bla2data&#60;/test3&#62;
&#60;/test&#62;
&lt;/pre&gt;

What would the sortfunction look like?

&lt;pre class="code"&gt;
private function sortXLC():void {
    var nameSort:Sort = new Sort();
    nameSort.fields = [new SortField("test.test2", true)]; // This wont work...

    factoryMethodsXLC.sort = nameSort;
    factoryMethodsXLC.refresh();
}
&lt;/pre&gt;

-Sjoerd</description>
		<content:encoded><![CDATA[<p>What about a XML that looks like this:</p>
<pre class="code">
&lt;test name="groupname"&gt;
    &lt;test2 name="old"&gt;bla1data&lt;/test2&gt;
    &lt;test3 name="new"&gt;bla2data&lt;/test3&gt;
&lt;/test&gt;
</pre>
<p>What would the sortfunction look like?</p>
<pre class="code">
private function sortXLC():void {
    var nameSort:Sort = new Sort();
    nameSort.fields = [new SortField("test.test2", true)]; // This wont work...

    factoryMethodsXLC.sort = nameSort;
    factoryMethodsXLC.refresh();
}
</pre>
<p>-Sjoerd</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mare</title>
		<link>http://blog.flexexamples.com/2007/08/22/sorting-and-filtering-data-in-an-xmllistcollection/#comment-1696</link>
		<author>mare</author>
		<pubDate>Mon, 10 Sep 2007 19:40:23 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/08/22/sorting-and-filtering-data-in-an-xmllistcollection/#comment-1696</guid>
		<description>Helped. Thanks.</description>
		<content:encoded><![CDATA[<p>Helped. Thanks.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
