Quick tips on Spry's new PagedView feature

Here are a few quick tips if you want to use the new PagedView support in Spry (remember, this code isn’t yet in the “released” version).

First - if you want to use sorting with PagedView datasets, you sort the original dateset, not the PagedView. So imagine this code:

var dsContent = new Spry.Data.XMLDataSet("/index.cfm?event=xml.getcontent&dd_class=#class.getID()#","content/content"); dsContent.setColumnType("DOWNLOADS","number");

var pvContent = new Spry.Data.PagedView(dsContent, { pageSize: 5 }); </code>

I was doing my sort like so:

<th onclick="pvContent.sort('DOWNLOADS','toggle')">DOWNLOADS</th>

But the proper way is to sort the original dataset:

<th onclick="dsContent.sort('DOWNLOADS','toggle')">DOWNLOADS</th>

Secondly, Kin Blas (One of the Spry Guys), posted a quick fix to the Spry forums. Add this line of code to the bottom of SpryPagedView.js:

Spry.Data.PagedView.prototype.onPostSort = Spry.Data.PagedView.prototype.onDataChanged;

So - next on my plate is a demo that shows how to use paging both client side and server side. In other words, Spry will grab a portion (like 100 rows) of the total (lets go crazy and say one million rows total) and then let you page over “pages of pages” I suppose we can say.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate for Extend by Auth0. He focuses on serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support.

Lafayette, LA https://www.raymondcamden.com

Comments