ColdFusion 8: Bug with cfsprydataset and Spry Paged Views
Related Categories: ColdFusion AJAX,
So I'm playing with cfsprydataset and some existing Spry code I had that uses Spry Paged Views. Turns out the Spry.Data.PagedView() cannot bind to dataset created by cfsprydataset. The workaround that I have found is to manually create a Spry dataset with the same name and type used in the cfsprydataset call. This allows the local Spry.Data.PagedView() to bind to the local dataset.
<script type="text/javascript" src="/CFIDE/scripts/ajax/spry/includes/SpryPagedView.js"></script>
<script type="text/javascript">
//Spry.Data.Region.debug = true;
var dsArtists = new Spry.Data.JSONDataSet("datapump.cfc?queryFormat=column&method=getArtists", {path: 'DATA', pathIsObjectOfArrays: true});
var pvArtists = new Spry.Data.PagedView(dsArtists, {pageSize: 5});
var pageOffset = 0;
var pageSize = 5;
var pageStop = pageOffset + pageSize;
</script>
Oddly enough there's only one AJAX call and dataset retrieved. I've attached some code samples that run against the CF8 example database. I've also sent this to the Spry team to see if I'm missing something.
Update: I filed bug 70562 for this issue.



[Add Comment] [Subscribe to Comments]
I ran acros the same problem today. Specially when using <cfsprydataset ... > inside a <cflayoutarea ... > with url-binding. After a couple of hours I've found the reason for that behaviour. When loading content asynchrounously using url-bindings, ColdFusion and yui/ext respectively, encapsulate contained scripts into an object. Now, if you define the page view as private variable (by using the var keyword), it is not shared with the main page wehere the Spry-scripts are included. As a result of this, they cannot access the dsArtists / pvArtists object in your example. Just removing the var keyword might help in this case...
Regards, Cyrill