Excellent! Thanks Jim. Getting closer, but still no cigar. 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 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. On Monday, 1 October 2012 18:19:14 UTC+2, Jim S wrote: > > You can pass constraints on to linked tables using the following: > > constraints={'contact':query,'yourtablename':yourconstraintquery} > > SQLFORM.smartgrid(db.contact, fields=fields, constraints=constraints, > orderby=orderby, create=create, details=details, editable=editable,deletable > =deletable, > csv=False, search_widget=searchForms, paginate=15, maxtextlength=45) > > You can also provide custom search forms for each downstream linked table > by passing a dict of the search form methods. > > Once you really get in to the smartgrid, it isn't hard at all to deviate > from what comes out of the box. > > -Jim > > > On Monday, October 1, 2012 9:08:40 AM UTC-5, Dominic Cioccarelli wrote: > >> Hi all, >> >> ok, making more and more progress with smartgrid but still a couple of >> gaps. >> >> I have a model structure which, simplifying things somewhat, has a >> hierarchy A-.>B->C. >> >> samrtgrid allows me to set up the model structure and then simply define >> a controller and view for A: I get the CRUD web pages for B & C for free. >> >> My question is, what happens if I need to customise one of these >> automatically generated sub-pages. e.g., after navigating from A to B to C >> I will have a list of all C's that belong to the B I chose (y) from A (x). >> The URI will be: >> >> http://mysite/app/A/index/A/B.a_id/x/C.b_id/y >> >> So now I'm 2 levels down and I only defined a single controller at the >> top level. I need to implement a check box which constrains the C's that >> I'm seeing on this page. >> >> I'm very impressed by how much you can do with so little in smartgrid but >> a but frustrated when you need to deviate from what you get for "free". >> >> Thanks in advance. >> >> Ciao, >> Dominic. >> >> > --