Right, but you can pass a query along in the constraints argument. Here is a sample pulled from one of my apps:

    #  Build query
    if searchText and searchText .strip() != '':
        queries.append(db.asset.description.contains(searchText))
    if assetTypeId and assetTypeId > 0:
        queries.append(db.asset.assetTypeId==assetTypeId)
    if len(queries) > 0:
        query = reduce(lambda a,b:(a&b),queries)
        constraints={'asset':query}

    #  Setup search forms
    searchForms = {'asset':assetSearch}

    grid = SQLFORM.smartgrid(db.asset, fields=fields,
                             constraints=constraints, orderby=orderby,
                             create=create, details=details,
                             editable=editable, deletable=deletable,
csv=False, search_widget={'asset':assetSearch},
                             searchable=True,
                             paginate=15, maxtextlength=45)

    -Jim


On 12/21/2011 12:20 PM, Cliff wrote:
In business applications it is generally a bad idea to delete records
of purchases, sales, etc.

At the same time you want indexes to include records of active things,
such as active customers.

A simple way to manage this requirement is to use an is_active boolean
field.  Then in your index function your query includes
is_active==True.   Additionally you would have a function called
"trash" where is_active==False.

My problem is I want to use smartgrid and smartgrid doesn't accept
queries.

One solution is to have, for example, a "customers" table and an
"inactive_customers" table and move record from table to table.

Surely someone can suggest a better way.

Any and all suggestions gratefully accepted.

Thanks,
Cliff Kachinske

Reply via email to