Matthew H
Matthew H

Reputation: 5879

How to implement Google-style pagination on app engine?

See the pagination on the app gallery? It has page numbers and a 'start' parameter which increases with the page number. Presumably this app was made on GAE. If so, how did they do this type of pagination? ATM I'm using cursors but passing them around in URLs is as ugly as hell.

Upvotes: 0

Views: 1174

Answers (2)

Nick Johnson
Nick Johnson

Reputation: 101149

You can simply pass in the 'start' parameter as an offset to the .fetch() call on your query. This gets less efficient as people dive deeper into the results, but if you don't expect people to browse past 1000 or so, it's manageable. You may also want to consider keeping a cache, mapping queries and offsets to cursors, so that repeated queries can fetch the next set of results efficiently.

Upvotes: 1

Adam Crossland
Adam Crossland

Reputation: 14213

Ben Davies's outstanding PagedQuery class will do everything that you want and more.

Upvotes: 1

Related Questions