Quick tips on Spry's new PagedView feature

This post is more than 2 years old.

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 });

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 senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

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

Archived Comments

Comment 1 by Bruce posted on 1/3/2007 at 3:38 AM

Thanks Ray. I was wondering why sorting was not working in my paged Spry DataSet.

I look forward to your example of paging using both client and server.

Comment 2 by Sami Hoda posted on 1/3/2007 at 4:55 AM

Ray,

Keep 'em coming. I'm keen to see this!

Sami

Comment 3 by Boyan posted on 1/3/2007 at 6:17 AM

Ray,

somewhat unrelated question here. I that you can tie events with onclick="dsContent.sort('DOWNLOADS','toggle'). Can you also tie events in a similar manar as you would in prototype: Event.Observe('click', 'elementID', functionToCall)?

Comment 4 by Raymond Camden posted on 1/3/2007 at 7:39 AM

Boyan - no. You _can_ tie evens to datasets obviously - in multiple ways. But you can't use Spry to add event handlers to NON Spry stuff (as this was - the onclick was on a th). At least as far as I know.