I am using sqlform.grid, with links that show details in a div when 
clicked.  

here are some fragments of the code:

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="123456")

The View:
view_report.html
     {{=grid}}
     {{=LOAD('default','report_details.load',ajax=True, target='details', 
user_signature=True ,vars={"Rnr_id":dummynr})}}

def render_FIELD():
    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'))

The loaded  view:
report_details.load
     {{=report.detail}}

The function 
def report_details()
    row_id = request.vars['Rnr_id']
    table = "tbl_reports"
    field = "id"
    q =(db[table][field]==row_id) 
    s = db(q)
    row = s.select().first()
    return dict(report=row)

This works fine. 
When the links are clicked the details are show.

However, when the page loads the first time I need to the dummynr to 
prevent  an "None" error.

How can I make the page to load and select the top record in the grid 
automatically and show the details as if the link was clicked?

The same applies to  changing pagination and 

what about handling sorting ? Is it possible to select the top record after 
the user has clicked the column to be sorted?

Any hint are very welcome.










-- 
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.

Reply via email to