Changes between Version 27 and Version 28 of ServerSidePagination


Ignore:
Timestamp:
01/20/10 05:40:54 (15 years ago)
Author:
Fran Boon
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ServerSidePagination

    v27 v28  
    4242{{{
    4343{
    44 "rEcho": 1,
     44"sEcho": 1,
    4545"aaData": [
    4646    [row1.id, row1.field2, ...],
     
    5555{{{
    5656def callback():
    57     print request.vars
     57    iDisplayStart = int(request.vars.iDisplayStart)
     58    iDisplayLength = int(request.vars.iDisplayLength)
    5859    from gluon.serializers import json
    59     query = ....
    60     rows = db(query).select() #<<<
    61     r=dict(rEcho=1,
    62            iTotalRecords=len(rows),
    63            iTotalDisplayRecords=len(rows),
    64            aaData=[[row.field1,row.field2] for row in rows])
     60    _table = '%s_%s' % (request.controller, request.function)
     61    table = db[_table]
     62    query = (table.id > 0)
     63    rows = db(query).select(limitby = (iDisplayStart, iDisplayStart + iDisplayLength))
     64    r = dict(sEcho = 1,
     65           iTotalRecords = len(rows),
     66           iTotalDisplayRecords = len(rows),
     67           aaData = [[row[f] for f in table.fields if table[f].readable] for row in rows])
    6568    return json(r)
    6669}}}
    67 If you print request.vars you can easy figure out what paramers are being passed and change the <<< line accordingly.
     70
    6871=== JSON Back-end implementation ===
    6972 * Support already present in {{{modules\s3xrc.py}}}