REF: SQLFORM.smartgrid() changing the table labels

675 views
Skip to first unread message

Teddy Nyambe

unread,
Mar 13, 2013, 10:08:29 AM3/13/13
to web2py
Is there a way to change the labels of the tables in the generated breadcrumbs of the SQLFORM.grid as well as the link pointing to the linked tables to something custom.



--
.......................................................................................
Teddy Lubasi Nyambe
Opensource Zambia
Lusaka, ZAMBIA

Cell: +260 97 7760473
website: http://www.opensource.org.zm

~/
Human Knowledge belongs to the world! - AntiTrust

Man is a tool-using animal. Without tools he is nothing, with tools he is all - Thomas Carlyle 1795-1881

/~

Cliff Kachinske

unread,
Mar 13, 2013, 10:22:59 AM3/13/13
to web...@googlegroups.com
db.define_table('myfeet',
    Field(...)
    ...,
    singular='Foot',
    plural='Feet',
    )

Jim S

unread,
Mar 13, 2013, 11:03:34 AM3/13/13
to web...@googlegroups.com
Or you can do it in code after the table is defined using:

db.myfeet._plural = 'Feet'
db.myfeet._singular = 'Foot'

-Jim

Niphlod

unread,
Mar 13, 2013, 11:08:49 AM3/13/13
to web...@googlegroups.com
bad for lazy_tables though.

Alex Glaros

unread,
Mar 13, 2013, 11:55:56 AM3/13/13
to
In smartgrid, the user first sees the parent records.  There is a link to the child table records on the far right for each parent record that has children.

Is there a way to change the name of the child table link on the far right from default "child_Table_name" to "Click_here_to_see_details_for_this_item" ?

Or is there a way to display a message near the link "Click here to see this item's details" ?

thanks,

Alex Glaros

Jim S

unread,
Mar 13, 2013, 12:14:21 PM3/13/13
to web...@googlegroups.com
I'm pretty sure that is what we've been talking about.  I think it uses the _plural value for the child table.  If this isn't what you were getting at post some code/screen shots so there isn't any confusion.

-Jim

On Wednesday, March 13, 2013 10:54:47 AM UTC-5, Alex Glaros wrote:
In smartgrid, the user first sees the parent records.  There is a link to the child table records on the far right for each parent record that has children.

Is there a way to change the name of the child table link on the far right from default "child_Table_name" to "Click_here_to_see_details_for_this_item" ?

Or is there a way to display a message near the link "Click here to see this item's details" ?

thanks,

Alex Glaros

On Wednesday, March 13, 2013 8:03:34 AM UTC-7, Jim S wrote:

Alex Glaros

unread,
Mar 13, 2013, 12:33:08 PM3/13/13
to web...@googlegroups.com
My question isn't related to singular/plural but completely renaming the child table display name so the table name displays as "Click_here" instead of "Child_table_name".  Let me know if you need screen shots.

Jim Steil

unread,
Mar 13, 2013, 12:57:43 PM3/13/13
to web...@googlegroups.com
I'm having trouble seeing the difference.  If you put the change to _plural in your controller then it is always there for that controller.  If you want it permanent, put it in your model.  Maybe a screen shot would help me better understand.  


--
 
---
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/Ft6b7SabnBM/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Alex Glaros

unread,
Mar 13, 2013, 2:39:44 PM3/13/13
to web...@googlegroups.com
I may be on the wrong topic.  Anyway, see attachment.
jim.jpg

Jim Steil

unread,
Mar 13, 2013, 4:36:31 PM3/13/13
to web...@googlegroups.com
...and doesn't changing the _plural value of that table change it?  It should!

Alex Glaros

unread,
Mar 13, 2013, 4:59:36 PM3/13/13
to web...@googlegroups.com
Yeah, it worked great.

Thanks Jim,

Alex

Jim Steil

unread,
Mar 13, 2013, 5:00:36 PM3/13/13
to web...@googlegroups.com
Glad to hear

Alex Glaros

unread,
Mar 13, 2013, 5:41:16 PM3/13/13
to
can anyone point to any examples where there is a running count of detail records for each parent?

Parent_one     link_to_child   3 records
Parent_two     link_to_child   0 records
Parent_three   link_to_child   10 records

this is so that users don't have to click on the Parent_two link to find out there are no child records for that Parent

Derek

unread,
Mar 13, 2013, 5:52:28 PM3/13/13
to web...@googlegroups.com
You'd add a virtual field for that.



On Wednesday, March 13, 2013 2:40:06 PM UTC-7, Alex Glaros wrote:
can anyone point to any examples where there is a running count of detail records for each parent?

Parent_one     link_to_child   3 records
Parent_two     link_to_child   0 records
Parent_three   link_to_child   10 records

this is so that users don't have to click on the Parent_two link to find out there are no child records for that Parent




On Wednesday, March 13, 2013 7:08:29 AM UTC-7, software.ted wrote:

Jim S

unread,
Mar 13, 2013, 9:42:33 PM3/13/13
to web...@googlegroups.com
...but you can't use them in .grid and .smartgrid.

from the book...

Mind that virtual fields do not have the same attributes as the other fields (default, readable, requires, etc) and they do not appear in the list of db.table.fields and are not visualized by default in tables (TABLE) and grids (SQLFORM.grid, SQLFORM.smartgrid).

-Jim

Jim S

unread,
Mar 13, 2013, 9:43:36 PM3/13/13
to web...@googlegroups.com
Just re-read my post and saw that it says they aren't visualized by default.  Does that mean there is a way to get them to be displayed?

-Jim
Reply all
Reply to author
Forward
0 new messages