Hi, to get the field to show correctly you have to set your locale
appropriately (see the Python manual) otherwise %f will use the
default (dot for decimal point).

Also keep in mind that widgets (validators have default ones) control
the presentation during input (the C&U in CRUD) while represent is
used for output (the R in CRUD).


On Nov 23, 7:44 am, Freerk Kalsbeek <[email protected]> wrote:
>  Hi Massimo,   Digged into it a little further, and found out that this only 
> happens when represent is used.   ##models.py db.define_table('all_values',   
>   
> Field('price','decimal(5,2)',requires=IS_DECIMAL_IN_RANGE(0,10,dot=','),represent
>  = lambda price,row: '€ %.2f' % price)     )   ## Controller: 
> @auth.requires_login() def index():     grid=SQLFORM.grid(db.all_values.id>0) 
>     form=grid.element('form')     if form and form.accepted:         
> response.flash='Verwerkt'     return dict(grid=grid)   ##view {{extend 
> 'layout.html'}} {{=grid}}   Screenshot 
> at:http://dl.dropbox.com/u/31865598/Schermafdruk.png  But maybe represent is 
> not the best approach to get units being displayed??   Grtz,   Freerk
>
>
>
> -----Oorspronkelijk bericht-----
> Aan:web2py-users <[email protected]>;
> Van:Massimo Di Pierro <[email protected]>
> Verzonden:di 22-11-2011 15:21
> Onderwerp:[web2py] Re: Formatting numbers in SQLFORM grid
> Can you provide an example? Wat do you mean in list view?
>
> On Nov 22, 6:41 am, Freerk Kalsbeek <[email protected]> wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > I'm trying to format numbers according to the dutch standard (decimal
> > comma separator).
>
> > It is working on view/edit views by adding:
> > requires=IS_DECIMAL_IN_RANGE(0,100,dot=',') to the numeric field.
> > But in list views the numbers are displayed with a decimal dot.
>
> > How can I change that?
>
> > Regards,
> > Freerk

Reply via email to