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.
Archived Comments
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.
Ray,
Keep 'em coming. I'm keen to see this!
Sami
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)?
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.