Just tried that, but it still returns the Id .. 1. it just returns a ticket if
On Sep 15, 12:57 am, Martín Mulone <[email protected]> wrote: > Perhaps you want to use columns instead of fields. > > replace your controller with this: > > def index(): > columns = ['dog.name', 'dog.owner'] > table = SQLFORM.grid(db.dog, columns=columns) > return dict(table=table) > > columns affect the grid column displaying only. Pass to column the field you > want to display, no need to put readable=False. > > 2011/9/14 Simon Ashley <[email protected]> > > > > > > > > > > > While it could be a bug, and seems to be similar to another reported > > issue: > > >http://groups.google.com/group/web2py/browse_thread/thread/aa5fa98a74... > > there has been no formal acknowledgement of it in .grid or .smartgrid, > > nor have there been any defect tickets raised. > > > You can also see it in a screenshot that Bruno Rocha posted recently: > > http://www.diigo.com/item/image/121xl/3iob > > It leads me to think that there may be an alternative method, > > particularly when 1.99.1. is due shortly. > > > Cheers, > > > (apologies if there are a number of similar posts from me. > > The first 2 seemed to be accepted, but haven't appeared yet. > > This is posted using a different account) > > > On Sep 14, 12:11 am, Jim Steil <[email protected]> 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? > > -- > http://martin.tecnodoc.com.ar

