My controller:
def pwrtable():
powerTable.dtfeatures['sScrollY'] = '100%'
powerTable.dtfeatures['sScrollX'] = '100%'
powerTable.headers = 'fieldname:capitalize'
powerTable.showkeycolumn = False
powerTable.dtfeatures['bJQueryUI'] = request.vars.get('jqueryui',True)
powerTable.uitheme = request.vars.get('theme','redmond')#'smoothness' /
'redmond' /'cupertino'
powerTable.dtfeatures['sPaginationType'] =
request.vars.get('pager','scrolling') # two_button full_numbers
powerTable.dtfeatures['sScrollXInner'] = '100%'
powerTable.dtfeatures['bScrollCollapse'] = True
powerTable.dtfeatures['bScrollInfinite'] = True
powerTable.dtfeatures['iScrollLoadGap'] = 10
powerTable.dtfeatures['bAutoWidth'] = True
powerTable.dtfeatures['bPaginate'] = True
powerTable.dtfeatures['bLengthChange'] = True
powerTable.dtfeatures['bInfo'] = True
powerTable.dtfeatures['bProcessing'] = True
powerTable.dtfeatures['iDisplayLength'] = 20
powerTable.dtfeatures['iDisplayStart'] = 0
powerTable.dtfeatures['sDom'] = '<"top"i>rt<"bottom"flp<"clear">'
powerTable.dtfeatures['asStripClasses'] = ['odd','even']
powerTable.columnsearch = False
return (powerTable)
r1 = db((db.t_registration_form.active==True)&
(db.t_registration_form.f_attendee == db.auth_user.id
)
).select(db.auth_user.id,
db.auth_user.first_name,
db.auth_user.last_name,
db.auth_user.title,
db.t_registration_form.f_payment_postal_address,
db.t_registration_form.f_payment_physical_address,
db.t_registration_form.f_accommodation_week1,
db.t_registration_form.f_accommodation_week2,
db.t_registration_form.f_agree,
orderby=db.t_registration_form.course_week1|db.t_registration_form.course_week2)
pt = pwrtable()
pt.source = r1
pt.headers = "fieldname:capitalize"
pt.truncate = 255
pt.keycolumn = 'auth_user.id'
pt.columnsearch = True
rows = pt.create()
#rows = SQLTABLE(r1, headers="fieldname:capitalize")
return dict(rows = rows, message = message)
When I use this I get the following error:
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
Traceback (most recent call last):
File "/home/js/web2py/gluon/restricted.py", line 188, in restricted
exec ccode in environment
File "/home/js/web2py/applications/ada/controllers/default.py"
<http://localhost:8000/admin/default/edit/ada/controllers/default.py>,
line 253, in <module>
File "/home/js/web2py/gluon/globals.py", line 95, in <lambda>
self._caller = lambda f: f()
File "/home/js/web2py/gluon/tools.py", line 2349, in f
return action(*a, **b)
File "/home/js/web2py/applications/ada/controllers/default.py"
<http://localhost:8000/admin/default/edit/ada/controllers/default.py>,
line 238, in show_registrations
rows = pt.create()
File "/home/js/web2py/applications/ada/models/plugin_powertable.py"
<http://localhost:8000/admin/default/edit/ada/models/plugin_powertable.py>,
line 810, in plugin_powertable
PowerTable(),
File "/home/js/web2py/applications/ada/models/plugin_powertable.py"
<http://localhost:8000/admin/default/edit/ada/models/plugin_powertable.py>,
line 219, in __init__
_id = record.id
File "/home/js/web2py/gluon/dal.py", line 3241, in __getattr__
return self[key]
File "/home/js/web2py/gluon/dal.py", line 3232, in __getitem__
return dict.__getitem__(self, key)
KeyError: 'id'
Why? If I Do not select db.auth_user.id and comment the pt.keycolumn = ...
line the same happens. There is no problem when I use either selection with
SQLTABLE.
Regards
Johann
--
May grace and peace be yours in abundance through the full knowledge of God
and of Jesus our Lord! His divine power has given us everything we need for
life and godliness through the full knowledge of the one who called us by
his own glory and excellence.
2 Pet. 1:2b,3a