Using db.table.format (i.e. format attr outside of table definition)

64 views
Skip to first unread message

Vlad

unread,
Jul 3, 2019, 10:17:18 AM7/3/19
to web2py-users
Using the following

db.table.format = lambda row: 'test'

before SQLFORM.grid creation doesn't seem to work.

What's the proper way to set record representation outside of table definition?

Vlad

unread,
Jul 7, 2019, 6:25:01 PM7/7/19
to web2py-users
Please help! Any way to use this format property outside of a table definition?

Val K

unread,
Jul 8, 2019, 1:19:56 PM7/8/19
to web2py-users
Try db.table._format=...

Eliezer (Vlad) Tseytkin

unread,
Jul 8, 2019, 2:54:06 PM7/8/19
to web...@googlegroups.com
Nope, still doesn't work... 

On Mon, Jul 8, 2019, 1:20 PM Val K <valq...@gmail.com> wrote:
Try db.table._format=...

--
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 a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/pQYWSHh-Pys/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/536b2be5-50c9-483b-858f-247df07cba7f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Val K

unread,
Jul 9, 2019, 1:17:08 AM7/9/19
to web2py-users
Show your code, please

Eliezer (Vlad) Tseytkin

unread,
Jul 9, 2019, 8:30:52 AM7/9/19
to web...@googlegroups.com
Oh, I see, here is what's happening: 

I now have the following code: 

   db.product._format = lambda row: 'test'
   grid = SQLFORM.grid(db.flavor)

The table flavor has a column referencing the table product. 

So, the grid displays the product column correctly now (with _format - this is where just 'format' doesn't work and '_format" does). However, when I add a new record to the flavor table (via the grid), I expect the product column in the insert record form to contain a drop down list of records from the product table to be represented by the same _format setting - perhaps I am making a wrong assumption? So this column in adding new record form ignores the _format. 

Is this by design? Isn't the format option supposed to work the same way in the new record form, as well as in the grid listing all the records? 

On Tue, Jul 9, 2019 at 1:17 AM Val K <valq...@gmail.com> wrote:
Show your code, please


--
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 a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/pQYWSHh-Pys/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.

Val K

unread,
Jul 9, 2019, 2:45:53 PM7/9/19
to web2py-users
I suppose it is also needed to add IS_IN_DB validator to the field that is reference
Reply all
Reply to author
Forward
0 new messages