There is no easy way but I just made a commit that fixes your problem. If you use trunk or wait for a next web2py version (within days) and you can do:
def stck_issue_manage(): #form = SQLFORM.smartgrid(db.t_stck_issue,onupdate=auth.archive) grid = SQLFORM.grid(db.t_stck_issue) if grid.dbset: myrow=grid.dbset.select(db.t_stck_issue.f_sub_total.sum())[0] answer=myrow._extra['SUM(t_stck_issue.f_sub_total)'] else: answer = None return locals() VIEW {{extend 'layout.html'}} <h2>Manage stck_issue</h2><p>{{=grid}}</p> <h2>All Issue Totals: {{=answer}}</h2> On Wednesday, 26 July 2017 08:27:33 UTC-5, kesh wrote: > > hello sir > i hope you are ok, well i have been having a problem with some code here > and have searched all over the internet but i was not able to get a solution > MODEL > db.define_table('t_stck_issue', > Field('f_name', type='reference t_items', > label=T('Name')), > Field('f_stck_client', type='reference t_clients', > label=T('Client Assgn')), > Field('f_stck_quantity', type='integer', > label=T('Stock Quantity')), > Field('f_unit_price', type='double', > label=T('Unit Price')), > Field('f_sub_total',type='double', compute=lambda > r:r['f_unit_price']*r['f_stck_quantity'], > label=T('Sub Total')), > auth.signature, > format='%(f_name)s', > migrate=settings.migrate) > > db.define_table('t_stck_issue_archive',db.t_stck_issue,Field('current_record','reference > > t_stck_issue',readable=False,writable=False)) > CONTROLLER > def stck_issue_manage(): > #form = SQLFORM.smartgrid(db.t_stck_issue,onupdate=auth.archive) > form = SQLFORM.grid(db.t_stck_issue) > myrow=db().select(db.t_stck_issue.f_sub_total.sum())[0] > answer=myrow._extra['SUM(t_stck_issue.f_sub_total)'] > return locals() > VIEW > {{extend 'layout.html'}} > > <h2>Manage stck_issue</h2><p>{{=form}}</p> > <h2>All Issue Totals: {{=answer}}</h2> > > well it calculates the sub total field for all properly, but i would like > it to change when i filter by client to do the sub total for that > particular client only > -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.