grid takes any query (even a join) smartgrid takes a table but (can) follow linked tables (no joins).
On Nov 9, 3:19 pm, Jim Steil <[email protected]> wrote: > From what I can gather, smartgrid is the same as grid except that it > will also display/work with related tables. Grid works with one table > only (please correct me if I'm wrong). > > -Jim > > On 11/9/2011 3:14 PM, Richard V�zina wrote: > > > > > > > > > Thank a lot Jim I will play a bit with your example... Pretty helpful... > > > I would like to know more about the difference between grid and > > smartgrid... I just start to read the sqlhtml.py to understand better > > new grid and smartgrid... > > > Thanks again. > > > Richard > > > On Wed, Nov 9, 2011 at 4:07 PM, Jim Steil <[email protected] > > <mailto:[email protected]>> wrote: > > > Here is a sample of one of my controllers. > > > @auth.requires_permission('select', db.priceTemplate) > > def priceTemplates(): > > response.view='list.html' > > table = db.priceTemplate > > response.title = '%s - %s' % (response.section, table['_plural']) > > columns = ['priceTemplate.name', 'priceTemplate.plantId', > > 'priceTemplate.iwhsPosition', > > 'contactPriceTemplate.contactId'] > > > # Setup Permissions > > editable = auth.has_permission('update', table) > > create = auth.has_permission('create', table) > > deletable = auth.has_permission('delete', table) > > details = auth.has_permission('read', table) > > > orderby = dict(priceTemplate=[db.priceTemplate.name > > <http://db.priceTemplate.name>]) > > > db.contactPriceTemplate._plural = 'Contacts' > > > db.contactPriceTemplate.priceTemplateId.writable = False > > db.contactPriceTemplate.priceTemplateId.readable = False > > > grid = SQLFORM.smartgrid(db.priceTemplate, columns=columns, > > orderby=orderby, > > create=create, details=details, > > editable=editable, deletable=deletable, > > csv=False, search_widget=None, > > paginate=15, maxtextlength=45) > > return dict(grid=grid) > > > In it I'm setting read/write capabilities for one of the fields > > (notice that it isn't a field in the primary table, but a related > > table. I'm also using standard auth to test for permissions > > (thanks Anthony). I can control sorting for primary table and > > related tables. In looking at the method signature for > > SQLFORM.grid it appears that formstyle will work just like it did > > for CRUD. From what little I know, it would appear to me that the > > CSS styling is the same as CRUD so your CSS should work. > > > SQLFORM.smartgrid is amazing. If you have your models setup > > properly you can get highly sophisticated CRUD forms, with > > relationships with very little boilerplate code. Thanks Massimo! > > > -Jim > > > On 11/9/2011 2:55 PM, Richard wrote: > > > Hello, > > > I would like to know I can control generated form with > > SQLFORM.grid... > > I use to do extensively : > > > If user and group and permission and row field value: > > crud.table.field.readable =\ > > crud.table.field.writable =False > > form = crud.create, read or update(db.table) > > > And I customize my form a bit with CSS (crud.settings.formstyle = > > 'divs') so I would like to know if I can recycle my CSS with > > SQLFORM.grid?? > > > Thanks. > > > Richard

