As I know, at least this is manual's bug. In the mannual, it use <a href="{{=URL(args=[page+1])}}">next</a>
But, it will raise error, I use this line instead <a href="{{=URL(r=request, args=[page+1])}}">next</a> On 8月25日, 上午1時55分, Vidul Petrov <vidul.r...@gmail.com> wrote: > Not sure if this help, but you may want to take a look at this > Pagination class:http://packages.python.org/web2py_utils/paginate.html > > On Aug 24, 6:37 pm, dlin <dlin...@gmail.com> wrote: > > > ref:http://web2py.com/book/default/chapter/12#Pagination > > > In following code, there is two problem: > > 1. The 'next' button always show. And the len(rows) always = 2 > > 2. I don't know how to proper show the {{=rows}} without last row, I > > want to use the odd row background-color trick. > > > I wrote simliar code in default.py > > ----------------------------------------- > > def listall(): > > if len(request.args): page=int(request.args[0]) > > else: page=0 > > items_per_page=2 > > limitby=(page*items_per_page,(page+1)*items_per_page + 1) > > words= db().select(db.mytable.ALL, limitby=limitby) > > cols = [ 'mytable.' + c for c in db.mytable.fields()[1:]] > > hdrs = dict([(str(c),c.label) for c in db.mytable]) > > rows =SQLTABLE(words, > > headers = hdrs, > > columns=cols, > > truncate=32) > > rows['_id'] = 'rows' > > return dict(rows=rows, page=page, items_per_page=items_per_page) > > > And the view listall.html: > > ------------------------------- > > {{extend 'layout.html'}} > > {{=rows}} > > page:{{=page}} <br /> > > len(rows):{{=len(rows)}} <br /> > > > {{if page:}} > > <a href="{{=URL(r=request, args=[page-1])}}">previous</a> > > {{pass}} > > > {{if len(rows)>=items_per_page:}} > > <a href="{{=URL(r=request, args=[page+1])}}">next</a> > > {{pass}} > > > <script>jQuery("#rows tr:odd").css("background-color", "#bbbbff");</ > > script> > >