My problem is similar:
At first there is the table of persons "auth_user" with some additional
fields like a phone number and so on.
Now one persons ("A") writes something concerning another person ("B").
Let's sove it with a table
db.define_table('report',
Field('from_person', 'reference auth_user'),
Field('about_person', 'reference auth_user'),
Field('text'),
singular='REPORT',
plural='REPORTS')
A SQLFORM.smartgrid(db.auth_user, linked_tables=['report']) shows a grid
with two "REPORTS"-buttons:
Report
Auth users <http://127.0.0.1:8000/smartgridtest2/default/report/auth_user>
Add<http://127.0.0.1:8000/smartgridtest2/default/report/auth_user/new/auth_user>
Export<http://127.0.0.1:8000/smartgridtest2/default/report/auth_user/csv?keywords=>
2 records found
Id<http://127.0.0.1:8000/smartgridtest2/default/report/auth_user?keywords=&order=auth_user.id>
First
name<http://127.0.0.1:8000/smartgridtest2/default/report/auth_user?keywords=&order=auth_user.first_name>
Last
name<http://127.0.0.1:8000/smartgridtest2/default/report/auth_user?keywords=&order=auth_user.last_name>
E-mail<http://127.0.0.1:8000/smartgridtest2/default/report/auth_user?keywords=&order=auth_user.email>
1 jim smith [email protected]
REPORTS<http://127.0.0.1:8000/smartgridtest2/default/report/auth_user/report.from_person/1>
REPORTS<http://127.0.0.1:8000/smartgridtest2/default/report/auth_user/report.about_person/1>
View<http://127.0.0.1:8000/smartgridtest2/default/report/auth_user/view/auth_user/1>
Edit<http://127.0.0.1:8000/smartgridtest2/default/report/auth_user/edit/auth_user/1>
Delete <http://127.0.0.1:8000/smartgridtest2/default/report#null> 2 joesmith
[email protected]
REPORTS<http://127.0.0.1:8000/smartgridtest2/default/report/auth_user/report.from_person/2>
REPORTS<http://127.0.0.1:8000/smartgridtest2/default/report/auth_user/report.about_person/2>
View<http://127.0.0.1:8000/smartgridtest2/default/report/auth_user/view/auth_user/2>
Edit<http://127.0.0.1:8000/smartgridtest2/default/report/auth_user/edit/auth_user/2>
Delete <http://127.0.0.1:8000/smartgridtest2/default/report#null>
But the first button is not necessary, because the from_user is the current
user.
*Is it possible to remove (only) the first button?*
I have tried the parameter "links" to create my own button. It works, but
the two REPORTS remain.
"links_in_grid = True" removes every button.
Maybe it would be better if "links_in_grid" switches off only the default
buttons?
If somebody wants to try it - this is my controller:
def report():
grid = SQLFORM.smartgrid(db.auth_user,
linked_tables=['report'],
user_signature = False)
return locals()
By the way: there is always the plural form - what is the condition to
display the singular form?
Regards, Martin
2011/12/26 Jim Gregory <[email protected]>
> I am creating an application that has a one-to-many table that
> references the same table twice:
>
> db.define_table('product',
> Field('title', required=True, unique=True),
> Field('sku', required = True, unique=True),
> Field('description', 'text'),
> format = '%(title)s'
> )
>
> db.define_table('related_product',
> Field('product_id', db.product, writable=False),
> Field('product', 'reference product'),
> )
>
> If I create a smartgrid on the 'product' table using:
> def product():
> return dict(grid=SQLFORM.smartgrid(
> db.product,
> linked_tables=['related_product'],
> ))
>
> the "related_product" table appears twice because it references the
> "product" table twice. Any way to prevent this?
>
> -Jim
>