I already posted this as a continuation of an existing question, but I
figured it may be better to break it out into a separate thread...
What happens if I want the constraint to add to the existing constraints
that have been built by smartgrid? For example, if I have the model:
db.define_table('make',
Field('name'))
db.define_table('option',
Field('name'))
m3t.define_table('model',
Field('name'),
Field('make_id', db.make),
Field('option_id', db.option))
Then I make a controller as follows:
def index():
grid = SQLFORM.smartgrid(db.make,constraints=constraints)
return dict(grid=grid)
If I navigate to (for example)
Alfa Romeo -> Gulia (Gulia being a type of Alfa)
And I want to only display Gulias with alloy wheels, which constraint
should I define?
If I define something like:
query = option.name == 'Alloy Wheels'
constraints = {'model':query}
... I'll get all the cars (irrespective of make and model) that have alloy
wheels. What I want is all the Alfa Romeo Gulias with Alloy Wheels. On the
other hand I remove the constraint and navigate from "Alfa Romeo" to
"Gulia" I'll get all Alfa Romo Gulias. What I need is a constraint that is *
added* to the generated constraints.
Many thanks in advance,
Dominic.
--