Massimo

Here is a little demo app to display the problem. I tested against trunk updated about noon central time today.

Added this to db.py:


contact = db.define_table('contact',
    Field('contactId', 'id'),
    Field('name', length=50, required=True),
    format='%(name)s')
contact._plural = 'Contacts'

tag = db.define_table('tag',
    Field('tagId', 'id'),
    Field('name', length=50, required=True),
    format='%(name)s')
tag._plural = 'Tags'

contactTag = db.define_table('contactTag',
    Field('contactTagId', 'id'),
Field('contactId', db.contact, readable=False, writable=False, required=True, label='Contact'),
    Field('tagId', db.tag, required=True, label='Tag'))

contactTag.contactId.requires = IS_IN_DB(db, db.contact.id,
                                     '%(name)s', zero=('select contact'))
contactTag.tagId.requires = IS_IN_DB(db, db.tag.tagId,
                                      '%(name)s', zero=('select tag'))


Added this to default.py:

def contacts():
    columns = ['contact.name', 'contactTag.tagId']
    orderBy = dict(contact=[db.contact.name])

    contactTag._plural = 'Tags'
grid = SQLFORM.smartgrid(db.contact, columns=columns, details=False, orderby=orderBy,csv=False,paginate=15, maxtextlength=45)

    return dict(grid=grid)

def tags():
    columns = ['tag.name', 'contactTag.contactId']
    orderBy = dict(tag=[db.tag.name])

    contactTag._plural = 'Contacts'
grid = SQLFORM.smartgrid(db.tag, columns=columns, details=False, orderby=orderBy,csv=False,paginate=15, maxtextlength=45)

    return dict(grid=grid)

I then went to http://127.0.0.1:8000/testapp/default/tags and added a few tags... Then went to http://127.0.0.1:8000/testapp/default/contacts and added a contact....

then go back to http://127.0.0.1:8000/testapp/default/contacts and click on Tags. Then click on the query button. In the field drop-down, nothing appears:


    -Jim


On 11/4/2011 10:39 PM, Massimo Di Pierro wrote:
Can you post your code? I cannot reproduce your problem. Which web2py
version?

On Nov 4, 4:26 pm, Jim Steil<j...@qlf.com>  wrote:
Hi

Testing some stuff with SQLFORM.smartgrid.  When using the query/search
on a related table, the query doesn't present any fields in the dropdown
list and no matter what I put in the search field, it returns 'Invalid
query'.

Is anyone else seeing this problem as well?

      -Jim

--
Jim Steil
VP of Information Technology
Quality Liquid Feeds, Inc.
608.935.2345 office
608.341.9896 cell

<<inline: jiajfcdc.png>>

Reply via email to