db.define_table('customer',
Field('firstname'),
Field('lastname'),
Field('account'))
db.define_table('survey_data',
Field('customer_id', 'reference customer'),
Field('Q1'),
Field('Q2'),
Field('Q3'))
def customer_view:
query=((db.customer.account > 100) & (db.customer.id==db.survey_data.customer_id))
fields=[db.customer.firstname, db.customer.lastname]
grid=SQLFORM.grid(deletable=False, editable=False, paginate=100, query=query, fields=fields) return dict(grid=grid)
Have you considered SQLFORM.smartgrid?
if not request.args(0) in ['view']:
details = False
links = [lambda row: getProductionDisplayAnchor(row)]
grid = SQLFORM.grid(query, fields=fields,
orderby=orderby, left=left,
create=create, details=details,
editable=editable, deletable=deletable,
csv=False, search_widget=workorderSearch,
paginate=15, maxtextlength=45,
links=links, formstyle=my_formstyle, ui=grid_ui)
def getProductionDisplayAnchor(row):
"""
build the anchor tags for the action buttons on the Production list
page
"""
anchor = ''
try:
workorderId = row['workorder']['workorderId']
except:
workorderId = 0
if workorderId > 0:
anchor = A(SPAN(_class='glyphicon glyphicon-pencil') + (
' Record Usage' if db.workorder(workorderId).completed == None else 'View Usage'),
_href=URL('production', args=('view', 'workorder', workorderId),
user_signature=True),
_class='btn btn-default') or ''
return anchor
links
is used to display new columns which can be links to other pages. The links
argument must be a list of dict(header='name',body=lambda row: A(...))
where header
is the header of the new column and body
is a function that takes a row and returns a value. In the example, the value is a A(...)
helper.