The only field you listed in "fields" is db.owner.name, which belongs only 
to the db.owner table. So, when you display a db.dog table, no fields have 
been specified, so nothing to display. I'm not sure, but I think you can 
list db.dog fields in the "fields" list as well -- try that and see if it 
works.

Note, another way to control which fields are shown in a grid is to specify 
(possibly dynamically within the grid's action) the "readable" and 
"writable" attributes of the fields.

Anthony

On Thursday, April 11, 2013 8:10:27 PM UTC-4, [email protected] wrote:
>
> I have created a new application named 'charges' utilizing MySQL database 
> server.
>
> At the model (produce_tables.py):
> db.define_table('owner'
>                 ,Field('name','string'),
>                 ,Field('address','string')
>                 ,format='%(name)s'
>                 )
>
> db.define_table('dog'
>                 ,Field('dogname','string',length=15,label='Onoma Skylou')
>                 ,Field('owner',db.owner, label='Idioktitis',readable=False)
>                 ,format='%(dogname)s'
>                 )
> db.dog.id.readable = False
>
> At the controller (test.py):
> @auth.requires_login()
> def testStarter():
>     """This is to explore SQLFORM.smartgrid capabilities"""
>     grid = SQLFORM.smartgrid(db.owner,fields=[db.owner.name
> ],linked_tables=['dog'])
>     return locals()
>
> At the view (test/testStarter.html):
> {{extend 'layout.html'}}
> {{=grid}}
>
> I use appadmin to populate the owners table with an owner and the dogs 
> table with a dog for that owner.
>
> Then, at http://127.0.0.1/charges/test/testStarter the smartgrid is shown 
> for the master owner table and the 'dogs' link is shown ok. BUT: when you 
> click on the 'dogs' link no dog record is returned (although it says it has 
> found 1 record).
>
> If I change the smartgrid definition so as to remove the fields=[
> db.owner.name] argument, that is:
>
> def testStarter():
>     """This is to explore SQLFORM.smartgrid capabilities"""
>     grid = SQLFORM.smartgrid(db.owner,linked_tables=['dog'])
>     return locals()
>
> then everything works ok.
>
> ???
>
> Thank you all in advance
>
> Tom
>
> P.S. OS: Windows XP Professional, SP3
>        web2py version 2.4.6-stable+timestamp.2013.04.06.17.37.38 (Running 
> on Rocket 1.2.6
>        running web2py from source
>        Python version: 2.7
>

-- 

--- 
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.


Reply via email to