>
> I made following changes to make it work:
>
- When the fields rendered the first row is marked as topfield and stored
in session.topfield
- First time load or reload returns row.id = 0 and forces to row.id stored
in session.topfield
def view_report():
qry.reportnr.represent = render_FIELD(qry.reportnr)
fields = (qry.id,qry.detail, qry.reportnr,)
grid = SQLFORM.grid(qr,fields =fields,
orderby= qry.reportnr,
groupby = qry.reportnr,
create = False,
deletable = False,
editable = False,
showbuttontext=False,
csv=False,
maxtextlength = 64,
paginate = 10)
details = DIV("Details",_id="details")
return dict(grid=grid, details=details, dummynr="0")
The View:
view_report.html
{{=grid}}
<div id="details">
{{=LOAD('default','report_details.load',ajax=True, target='details',
user_signature=True ,vars={"Rnr_id":dummynr})}}
def render_FIELD():
def __init__(self):
self.topfield = True
def __call__(self,ids,row,col=None):
...
span.append(A(ids,callback=URL('default','report_details.load',
vars=dict(id=ids, Rnr_id=row.id)),target='details'))
if self.topfield:
session.topfield = row.id
self.topfield = False
The loaded view:
report_details.load
{{=report.detail}}
The function
def report_details()
row_id = request.vars['Rnr_id']
if row_id == '0':
row_id = session.topfield
table = "tbl_reports"
field = "id"
q =(db[table][field]==row_id)
s = db(q)
row = s.select().first()
return dict(report=row)
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.