<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: New version of RemoteList (IList implementation that support paging)</title>
	<link>http://blog.widget-labs.com/2007/01/21/new-version-of-remotelist-ilist-implementation-that-support-paging/</link>
	<description></description>
	<pubDate>Mon, 01 Dec 2008 22:49:25 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2</generator>

	<item>
		<title>By: Marcus Williford</title>
		<link>http://blog.widget-labs.com/2007/01/21/new-version-of-remotelist-ilist-implementation-that-support-paging/#comment-1168</link>
		<author>Marcus Williford</author>
		<pubDate>Wed, 27 Feb 2008 03:56:57 +0000</pubDate>
		<guid>http://blog.widget-labs.com/2007/01/21/new-version-of-remotelist-ilist-implementation-that-support-paging/#comment-1168</guid>
		<description>Thanks for posting this code, it is a great contribution.  I added sort for my tests.

I just implemented sort by wrapping the RemoteList and extending ListViewCollection, which dataGrid wraps anyways.  I extend set sort and get sort, and mess with the the query that gets issued against my webcall.  I also had to add some refresh() logic to removeAll data and make sure the CollectionChange events fire properly so the grid will see the new data after the sort/refresh() gets executed.

Other modifications and notes:

1.  I added the dataField to the datagridcolumn (even though I was using an itemrenderer and didn't need it), so it would have something in the "name" column of the SortField.  This is important to capture which field the user selected for sort.  The override means the sort object will get passed when datagrid headers are selected.
2.  I added set sort to the interface and other classes, so my implementation of RemoteDataSet gets the sort object.  Now I can use this sort object to influence my query string that I build (for my xml service).  I sort on the server side, so I only pull what the user is viewing.
3.  I went back and fourth regarding itemPendingError, tried both ways, I almost like the fake "loading" objects better in some ways. 
4.  Datagrid will call set sort(value:Sort) and refresh() on this class, just make sure that alters your webservice query, invalidates data, updates a new length, then throws a collectionchange event.


RemoteCollectionView class ( to be used as a sort capable wrapper) instead of RemoteList.
-------------------------------------------------------
{
	import mx.collections.ICollectionView;
	import mx.collections.ListCollectionView;
	import mx.collections.Sort;

	public class RemoteCollectionView extends ListCollectionView implements ICollectionView
	{
		
		/**
		 * 
		 * Utilize ListCollectionView for most operations, only override what we need to to add sort functionality
		 * 
		 **/
		public function RemoteCollectionView(rList:RemoteList)
			{
			super(rList);
			
		}
		
		public function set query(value:String):void {
			RemoteList(this.list).query = value;
		}

		private var _sort:Sort;
		
		public var sortField:String;
		public var descending:Boolean;
	
 		override public function get sort():Sort {
 			return null; // never use internal sort to sort this remote collection
 		}
 		override public function set sort(value:Sort):void
		{
			_sort = value;
			RemoteList(this.list).sort = _sort;
		}
		
		override public function refresh():Boolean {
			RemoteList(this.list).refresh();
			return true;
		}
	}
}

I'll try to wrap this up into a project or something when I get more time.  I just wanted to share these modifications, as it really worked out great.

Thanks,
Marcus Williford</description>
		<content:encoded><![CDATA[<p>Thanks for posting this code, it is a great contribution.  I added sort for my tests.</p>
<p>I just implemented sort by wrapping the RemoteList and extending ListViewCollection, which dataGrid wraps anyways.  I extend set sort and get sort, and mess with the the query that gets issued against my webcall.  I also had to add some refresh() logic to removeAll data and make sure the CollectionChange events fire properly so the grid will see the new data after the sort/refresh() gets executed.</p>
<p>Other modifications and notes:</p>
<p>1.  I added the dataField to the datagridcolumn (even though I was using an itemrenderer and didn&#8217;t need it), so it would have something in the &#8220;name&#8221; column of the SortField.  This is important to capture which field the user selected for sort.  The override means the sort object will get passed when datagrid headers are selected.<br />
2.  I added set sort to the interface and other classes, so my implementation of RemoteDataSet gets the sort object.  Now I can use this sort object to influence my query string that I build (for my xml service).  I sort on the server side, so I only pull what the user is viewing.<br />
3.  I went back and fourth regarding itemPendingError, tried both ways, I almost like the fake &#8220;loading&#8221; objects better in some ways.<br />
4.  Datagrid will call set sort(value:Sort) and refresh() on this class, just make sure that alters your webservice query, invalidates data, updates a new length, then throws a collectionchange event.</p>
<p>RemoteCollectionView class ( to be used as a sort capable wrapper) instead of RemoteList.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
{<br />
	import mx.collections.ICollectionView;<br />
	import mx.collections.ListCollectionView;<br />
	import mx.collections.Sort;</p>
<p>	public class RemoteCollectionView extends ListCollectionView implements ICollectionView<br />
	{</p>
<p>		/**<br />
		 *<br />
		 * Utilize ListCollectionView for most operations, only override what we need to to add sort functionality<br />
		 *<br />
		 **/<br />
		public function RemoteCollectionView(rList:RemoteList)<br />
			{<br />
			super(rList);</p>
<p>		}</p>
<p>		public function set query(value:String):void {<br />
			RemoteList(this.list).query = value;<br />
		}</p>
<p>		private var _sort:Sort;</p>
<p>		public var sortField:String;<br />
		public var descending:Boolean;</p>
<p> 		override public function get sort():Sort {<br />
 			return null; // never use internal sort to sort this remote collection<br />
 		}<br />
 		override public function set sort(value:Sort):void<br />
		{<br />
			_sort = value;<br />
			RemoteList(this.list).sort = _sort;<br />
		}</p>
<p>		override public function refresh():Boolean {<br />
			RemoteList(this.list).refresh();<br />
			return true;<br />
		}<br />
	}<br />
}</p>
<p>I&#8217;ll try to wrap this up into a project or something when I get more time.  I just wanted to share these modifications, as it really worked out great.</p>
<p>Thanks,<br />
Marcus Williford</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: blog.widget-labs.com &#187; Blog Archive &#187; Short update on RemoteList implementation</title>
		<link>http://blog.widget-labs.com/2007/01/21/new-version-of-remotelist-ilist-implementation-that-support-paging/#comment-9</link>
		<author>blog.widget-labs.com &#187; Blog Archive &#187; Short update on RemoteList implementation</author>
		<pubDate>Tue, 13 Mar 2007 02:17:22 +0000</pubDate>
		<guid>http://blog.widget-labs.com/2007/01/21/new-version-of-remotelist-ilist-implementation-that-support-paging/#comment-9</guid>
		<description>[...] short update for RemoteList  [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] short update for RemoteList  [&#8230;]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
