Also I wonder, why would you say something like this: 2014 m. spalis 4 d., šeštadienis 20:08:50 UTC+1, Niphlod rašė: > > The thing you posted > """ > Same story here. I like *grid*, I like pagination, however I'm missing > the feature of limiting the total number of rows in the output. > In my case *grid* can easily generate over 1+m rows in the output, which > when paginating by 50 rows per page, would produce 20k+ pages... > Who needs that many pages? Who would click 20+k times anyway? > """ > doesn't point towards something the grid can fix. >
In fact, I think this is something that grid not just could, or perhaps should be doing, besides other great features - let user decide, how many rows (or pages) one wants. If Massimo is not a dirty liar and epydoc is up to date, pagination logic is as follows: #figure out what page we are one to setup the limitby 2364 if paginate and dbset._db._adapter.dbengine <http://web2py.com/examples/static/epydoc/gluon.sqlhtml-pysrc.html#>=='google:datastore': 2365 cursor = request <http://web2py.com/examples/static/epydoc/gluon.sqlhtml-pysrc.html#>.vars <http://web2py.com/examples/static/epydoc/gluon.sqlhtml-pysrc.html#>.cursor or True 2366 limitby = (0, paginate) 2367 try: page = int <http://web2py.com/examples/static/epydoc/gluon.sqlhtml-pysrc.html#>(request <http://web2py.com/examples/static/epydoc/gluon.sqlhtml-pysrc.html#>.vars <http://web2py.com/examples/static/epydoc/gluon.sqlhtml-pysrc.html#>.page or 1)-1 2368 except ValueError: page = 0 2369 elif paginate and paginate<nrows: 2370 try: page = int <http://web2py.com/examples/static/epydoc/gluon.sqlhtml-pysrc.html#>(request <http://web2py.com/examples/static/epydoc/gluon.sqlhtml-pysrc.html#>.vars <http://web2py.com/examples/static/epydoc/gluon.sqlhtml-pysrc.html#>.page or 1)-1 2371 except ValueError: page = 0 2372 limitby = (paginate*page,paginate*(page+1)) 2373 else: 2374 limitby = None So to put everything in the right order, all it takes is replacing few lines: usr_limitby = None # default value must be set somewhere try: pg_tail = usr_limitby % paginate except TypeError: limitby = (paginate*page,paginate*(page+1)) else: if pg_tail == 0: limitby=(paginate*page,int(usr_limitby/paginate)) else: limitby=(paginate*page,int(usr_limitby/paginate)+1) Or perhaps slicing *nrows.* I dunno, there might be other better ways to do it. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.