In the database, the value is stored as a string with the individual values
separated by pipe characters (i.e., "|a|b|"). However, when you select from
the DB using the DAL, the value gets converted to a list. list:string
fields get a default "represent" attribute that displays the values as a
comma-separated list in grids, etc., but you have to do it yourself or
explicitly call the "represent" function in other contexts:
DIV(', '.join(row.test))
or
DIV(db.test.test.represent(row.test))
Anthony
On Tuesday, April 16, 2013 10:37:20 PM UTC-4, 黄祥 wrote:
>
> hi folks,
>
> is it possible to change list:string type field output format?
>
> e.g.
> *in grid output : a, b*
> *in shell output : |a|b|*
> >>> print db(db.test.test.contains('b')).select()
> test.id,test.test
> 1,|a|b|
> *in view using query output : ab*
> {{for i, row in enumerate(rows):}}
> {{=DIV(row.test)}}
> {{pass}}
> *in view using query output : ['a', 'b']*
> {{for i, row in enumerate(rows):}}
> {{=DIV(str(row.test))}}
> {{pass}}
>
> i want to have the output format for list:string type field in view : *a,
> b* or *a; b* instead of ab. did anyone know how to produce the output
> like that in web2py?
>
> thank you very much in advance
>
--
---
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/groups/opt_out.