It would be convoluted. It is easier the way you are doing it.

On Tuesday, 14 August 2018 02:38:19 UTC-7, JSalvat wrote:
>
> Hi, How can this be done using  SQLFORM.grid  ?
>
> def groupgrid():
>     cant = db.emitida.id.count()
>     suma = db.emitida.total.sum()
>       rows = 
> db(db.emitida.numero.startswith('18')).select(db.emitida.empresa, cant, 
> suma, orderby=db.emitida.empresa, groupby=db.emitida.empresa)
>     head = {'emitida.empresa':'empresa',
>             'COUNT("emitida"."id")':'cant.',
>             'SUM("emitida"."total")':'total'}
>       grid = SQLTABLE(rows, headers=head)
>     return dict(grid=grid)
>
> Also I will like to apply style on amount column:
>
> suma.represent = lambda v, row: DIV(locale.format("%.2f", v, 
> grouping=True), _style="width: 100%; text-align:right;")
>
> Thanks for any valuable help!
>

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