开发者

How to implement Google-style pagination on app engine?

开发者 https://www.devze.com 2023-01-12 07:12 出处:网络
See开发者_JS百科 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

See开发者_JS百科 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.


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消