Ping! There is a question at the bottom of my last email if some one has any idea?
Thanks Richard On Wed, Nov 9, 2011 at 5:11 PM, Richard Vézina <[email protected]>wrote: > Ok I just read trunk sqlhtml.py that already have the patch I was about to > submit (Miss this easy one :) > > if create and len(request.args)>1 and request.args[-2]=='new': > check_authorization() > table = db[request.args[-1]] > create_form = SQLFORM( > table, > _class='web2py_form', > *formstyle = formstyle* > ).process(next=referrer, > onvalidation=onvalidation, > onsuccess=oncreate, > formname=formname) > > Just adding formstyle functionnality that is not present in 1.99.2... > > > Now I would like to know how I can intercept the html form before it get > in the face of the user... I mean I use to do this hack to show user help > bubble to the user : > > > form = crud.create(db[request.args(0)]) > for i in range(0,len(form[0])): > if len(form[0][i][2][0]) > 0: > form[0][i][0].append(SPAN((helpicon(), > SPAN(form[0][i][2][0])),_class='tooltip')) > del(form[0][i][2]) > > So I would do the same with create, update form generated by SQLFORM.grid > > Thanks for any suggestion. > > Richard > > On Wed, Nov 9, 2011 at 4:54 PM, Cliff <[email protected]> wrote: > >> In grid you can also do ... >> >> if 'new' in request.args: >> db.sometable.is_active.readable =\ >> db.sometable.is_active.writable =\ >> False >> >> query=db.othertable.otherfield==avalue >> db.sometable.foreign_key.requires =\ >> IS_IN_DB(db(query), 'othertable.otherfield' ...) >> >> # even more >> # for those times when the grid default form isn't sufficient >> form = SQLFORM(db.sometable, .....) >> if form.accepts(...) #old method, I know >> yada >> yada >> return dict(form=form) >> >> Haven't tried this in smartgrid yet. >> >> On Nov 9, 4:26 pm, Massimo Di Pierro <[email protected]> >> wrote: >> > 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 >> > >

