While it looks like a bug, it may not be implemented in the new .grid
or .smartgrid.
There is a posting that may imply this
http://groups.google.com/group/web2py/browse_thread/thread/aa5fa98a74e9364f
and certainly in image examples posted by Bruno Rocha
http://www.diigo.com/item/image/121xl/3iob it doesn't look like its
been implemented.
A little it odd seeing that 1.99.1 is due for release shortly.

cheers,


On Sep 14, 12:11 am, Jim Steil <j...@qlf.com> wrote:
> Is it possible that this is a bug?  (I don't have the
> expertise/confidence to say it is definitely a bug).    I duplicated
> your example and can reproduce your results.  But, if I go through
> appadmin and list out my table the owner name does appear.
>
>      -Jim
>
> On 9/12/2011 9:51 PM, Simon Ashley wrote:
>
>
>
>
>
>
>
> > Have a Model as follows:
>
> > from gluon.tools import Auth
> > auth=Auth(db)
> > auth.define_tables()
> > db.define_table('person',Field('name'),format='%(name)s')
> > db.define_table('dog',Field('name'),Field('owner',db.person))
> > db.dog.owner.requires = IS_IN_DB(db, 'person.id', db.person._format)
>
> > and a controller:
>
> > def index():
> >    db.dog.id.readable=False
> >    fields = (db.dog.id, db.dog.name, db.dog.owner)
> >    table = SQLFORM.grid(db.dog, fields)
> >    return dict(table=table)
>
> > Main issue:
> > the grid returns the id rather than the name for the owner.
> > Edit and view both return the name (as expected).
> > Is there a problem with the model/ controller syntax?
>
> > Side issue:
> > In the controller, fields line, if db.dog.id is left out, the grid
> > returns an id ticket error.
>
> > Traceback (most recent call last):
> >    File "gluon/restricted.py", line 194, in restricted
> >    File "C:/web2py/applications/pt2/controllers/dogs.py", line 7, in
> > <module>
> >    File "gluon/globals.py", line 145, in<lambda>
> >    File "C:/web2py/applications/pt2/controllers/dogs.py", line 4, in
> > index
> >    File "gluon/sqlhtml.py", line 1647, in grid
> >    File "gluon/dal.py", line 3835, in __getitem__
> > KeyError: 'id'
>
> > This occurs with or without the second line (... readable=False)
> > commented out.
> > Wanted to show the id in edit and view forms but not in the grid.
> > Can this be achieved?

Reply via email to