This one should work...

db.Product.List_Price.represent = lambda value, row: DIV('€ %.2f' % (0.0
if value == None else value), _style='text-align: right;')

On Wed, Sep 28, 2011 at 6:26 PM, Omi Chiba <ochib...@gmail.com> wrote:

> It's smartgrid so nothing really in default.py.
>
> just this one.
>
> def admin():
>    products = SQLFORM.grid(db.Product,deletable=False, paginate=10)
>    return dict(products = products)
>
> This is my table.
> db.define_table('Product',
>    Field('Part_Number'),
>    Field('List_Price', 'decimal(13,2)'))
>
>
> On Sep 28, 11:08 am, Jim Steil <j...@qlf.com> wrote:
> > Can you post the relevant code from default.py?
> >
> >      -Jim
> >
> > On 9/28/2011 11:02 AM, Omi Chiba wrote:
> >
> >
> >
> >
> >
> >
> >
> > > Jim,
> >
> > > close but I got a following error.
> >
> > > Traceback (most recent call last):
> > >    File "/home/www-data/web2py/gluon/restricted.py", line 194, in
> > > restricted
> > >      exec ccode in environment
> > >    File "/home/www-data/web2py/applications/pricelist/controllers/
> > > default.py", line 95, in<module>
> > >      @auth.requires_signature()
> > >    File "/home/www-data/web2py/gluon/tools.py", line 2494, in
> > > requires_signature
> > >      return
> > > self.requires(URL.verify(current.request,user_signature=True))
> > >    File "/home/www-data/web2py/gluon/html.py", line 352, in verifyURL
> > >      hmac_key = current.session.auth.hmac_key
> > > AttributeError: 'NoneType' object has no attribute 'hmac_key'
> >
> > > On Sep 28, 10:48 am, Jim Steil<j...@qlf.com>  wrote:
> > >> untested
> >
> > >> db.Product.List_Price.represent = lambda value, row: XML(DIV('$ %.2f'
> % (0.0 if value == None else value),_style='text-align: right;'))
> >
> > >> On 9/28/2011 10:42 AM, Omi Chiba wrote:
> >
> > >>> Um, actually one more question.
> > >>> Now I have two represent and riht now either one of them work but not
> > >>> both. How I can combine them together ??
> > >>> # Currency format
> > >>> db.Product.List_Price.represent = lambda value, row: '$ %.2f' % (0.0
> > >>> if value == None else value)
> > >>> # text-align: right
> > >>> db.Product.List_Price.represent = lambda value, row:
> > >>> XML(DIV(value,_style='text-align: right;'))
> > >>> On Sep 28, 10:37 am, Omi Chiba<ochib...@gmail.com>    wrote:
> > >>>> Wow ! This is what I want.
> > >>>> Thanks !!
> > >>>> On Sep 28, 9:53 am, Massimiliano<mbelle...@gmail.com>    wrote:
> > >>>>> Is there a reason that you want to format on the grid?
> > >>>>>    because you can do it in field.represent:
> > >>>>> db.yourtable.yourfield = lambda value, row: '$ %.2f' % (0.0 if
> value == None
> > >>>>> else value)
> > >>>>> On Wed, Sep 28, 2011 at 4:48 PM, Omi Chiba<ochib...@gmail.com>
>  wrote:
> > >>>>>> Can we format 500.00 to $500.00 on smartgrid ?
> > >>>>> --
> > >>>>> Massimiliano
>



-- 
Massimiliano

Reply via email to