[web2py] Re: No row buttons in SQLFORM.grid using groupby
I'm afraid you're right. I'll have to find another way of creating this table with a link to each row's main table/field. Thanks On Thursday, 10 October 2013 18:34:16 UTC+1, Derek wrote: > > If you are grouping then you can't access a specific ID. You'd just be > getting aggregates back. > > On Thursday, October 10, 2013 10:13:56 AM UTC-7, Luis Furtado wrote: >> >> If I call SQLFORM.grid with "groupby" I get a table with no row buttons >> ("view" in this case). >> Those buttons show up if I leave "groupby" out. But then I get duplicate >> records. >> Notice that I'm joining three tables; >> >> g=SQLFORM.grid( ((db.empresa.id == db.emp_prod.emp ) & >> (db.emp_prod.prod == db.nc.id) & >> (db.nc.nc.like( ncsel + '%')) ), >> fields = [ db.empresa.nome ], >> details =True, create = False, editable = >> False, deletable =False, searchable =False, csv =False, >> groupby = db.empresa.nome ) >> >> What should I do? >> Thanks >> Luis >> > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] No row buttons in SQLFORM.grid using groupby
If I call SQLFORM.grid with "groupby" I get a table with no row buttons ("view" in this case). Those buttons show up if I leave "groupby" out. But then I get duplicate records. Notice that I'm joining three tables; g=SQLFORM.grid( ((db.empresa.id == db.emp_prod.emp ) & (db.emp_prod.prod == db.nc.id) & (db.nc.nc.like( ncsel + '%')) ), fields = [ db.empresa.nome ], details =True, create = False, editable = False, deletable =False, searchable =False, csv =False, groupby = db.empresa.nome ) What should I do? Thanks Luis -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: Loop on form.process(). Validation is not done
No, I don't manage the form submission. Just use jQuery to: 1. fill in user_id 2. populate a select dropdown depending on an option on another select 3. add some titles in the form -- index.html {{ extend 'modelo.html' }} {{ =response.toolbar() }} R_ID = {{ =session.r_id }} {{=form}} jQuery( document).ready( function() { jQuery("#r_municipio__row" ).before("A - IDENTIFICAÇÃO DA EXPLORAÇÃO
") jQuery("#r_p_nome__row" ).before("B - PRODUTOR
") jQuery("#r_user_id").val( {{ =auth.user_id or 0 }} ) // Copia valor do user_id da sessao para o da tabela jQuery("#r_municipio").change( function () { $.get( "ajax_freguesia", "codconc="+ $("#r_municipio").val(), function (result) { $("#r_freguesia").html( result); } ) }) }); Now I just read M.di Pierro's reply and I will try web2py 2.0.9. Luis On Friday, 14 September 2012 17:05:23 UTC+1, rochacbruno wrote: > > What do you have in your view? are you using any JavaScript to manage the > form submission? --
[web2py] Re: Loop on form.process(). Validation is not done
I'm calling session.forget() to try and fix the problem, but it didn't. Anyway, the problem was there before that. I just removed it and it made no difference. The whole behaviour of the app is variable. Sometimes it does the validation phase and then I fill it w/o errors and, after submitting, the app. goes on to the 2nd form. Other times it just won't do any validation and restarts the app. When this happens, it usually goes to an URL like this: http://127.0.0.1:8000/nova/default/f_prod?_formkey=bd681283-abd1-4e18-885b-2597984db8ee&_formname=prod%2Fcreate&cmr_convenc=98&cmr_mpb=7&cmr_seco=&cmr_verde=&codigo=4600&r_id=40&_signature=344c90d0588ad87ce1f587024fe826ccf260d2dc When all goes well there are no GET args on the URL. I've checked in the html code created, it is . Another problem is it never executes "session.r_id = form.vars.id" after form accepted. Maybe I should address this in a different post. This is my 1st web2py app. What am I missing? Thanks Luis On Friday, 14 September 2012 09:10:59 UTC+1, Niphlod wrote: > > why are you calling session.forget() ? > > On Thursday, September 13, 2012 8:43:30 PM UTC+2, Luis Furtado wrote: >> >> Hello, >> When I submit the form no validation errors are shown and, after a few >> seconds, it just shows the form again, totally blank even if I had filled >> some fields. >> If I include @auth.requires_login() at index() it even gets back to login >> instead of the form. >> It seems as if the application is restarted when it tries to do the >> validation phase. >> >> --- MODEL >> db = DAL('sqlite://storage.sqlite') >> >> db.define_table( 'concelho', Field('codigo'), Field('nome'), >> format='%(nome)s') >> >> db.define_table( 'freguesia', >>Field('cod_concelho', requires= IS_IN_DB( db, db.concelho.codigo )), >>Field('codigo'), >>Field('nome'), >>format='%(nome)s' >> ) >> >> db.define_table( 'r', >>Field('user_id', 'integer'), >>Field('municipio', requires= IS_IN_DB( db, db.concelho.codigo, >> '%(nome)s')), >>Field('freguesia', requires= IS_IN_DB( db, db.freguesia.codigo, >> '%(nome)s')), >>Field('morada', requires= IS_NOT_EMPTY()), >>Field('cod_postal', requires= IS_MATCH('^\d{4}-\d{3}$')), >>Field('nif', requires= IS_MATCH('^\d{9}$')), >>Field('nat_juridica', requires= IS_IN_SET(['AUT','EMP','SOC'])), >>Field('ini_agricola', 'integer', requires= IS_EMPTY_OR( >> IS_INT_IN_RANGE( 1970, 2012))), >>Field('p_nome', requires= IS_NOT_EMPTY()), >>Field('nascimento', 'date', requires = IS_EMPTY_OR( IS_DATE( >> format='%Y-%m-%d'))), >>Field('escolaridade', requires = >> IS_IN_SET(['Básico','Secundário','Licenciatura','Mestrado'])) >> ) >> >> db.define_table( 'prod', >>Field('r_id', db.r ), >>Field('codigo', 'integer',label='Espécie', requires= IS_NOT_EMPTY()), >>Field('cmr_convenc', 'integer',label='Convencional', requires= >> IS_NOT_EMPTY()), >>Field('cmr_mpb', 'integer',label='M.P.Biológico',requires= >> IS_NOT_EMPTY()) >> ) >> -- CONTROLLER - >> def index(): >>session.forget() >>session.r_id = 40 # Initial value -- will be replaced by form.vars.id >> >>form = SQLFORM( db.r) >>if form.process( next=URL('f_prod') ).accepted: >> session.r_id = form.vars.id >> response.flash = 'Success (R_ID=%s)' % session.r_id >>elif form.errors: >> response.flash = 'ERRORS in the form' >>else: >> response.flash = 'Form 1 of 2' >> >>return dict( form=form) >> >> >> def f_prod(): >> >> RID = session.r_id >> >> form = SQLFORM( db.prod) >> if form.process().accepted: >>response.flash = 'Success' >> elif form.errors: >>response.flash = 'ERRORS' >> else: >>response.flash = 'Form 2 of 2' >> >> return dict( form=form, RID=RID) >> - >> What's wrong? >> Thanks >> Luis >> >> --
[web2py] Loop on form.process(). Validation is not done
Hello, When I submit the form no validation errors are shown and, after a few seconds, it just shows the form again, totally blank even if I had filled some fields. If I include @auth.requires_login() at index() it even gets back to login instead of the form. It seems as if the application is restarted when it tries to do the validation phase. --- MODEL db = DAL('sqlite://storage.sqlite') db.define_table( 'concelho', Field('codigo'), Field('nome'), format='%(nome)s') db.define_table( 'freguesia', Field('cod_concelho', requires= IS_IN_DB( db, db.concelho.codigo )), Field('codigo'), Field('nome'), format='%(nome)s' ) db.define_table( 'r', Field('user_id', 'integer'), Field('municipio', requires= IS_IN_DB( db, db.concelho.codigo, '%(nome)s')), Field('freguesia', requires= IS_IN_DB( db, db.freguesia.codigo, '%(nome)s')), Field('morada', requires= IS_NOT_EMPTY()), Field('cod_postal', requires= IS_MATCH('^\d{4}-\d{3}$')), Field('nif', requires= IS_MATCH('^\d{9}$')), Field('nat_juridica', requires= IS_IN_SET(['AUT','EMP','SOC'])), Field('ini_agricola', 'integer', requires= IS_EMPTY_OR( IS_INT_IN_RANGE( 1970, 2012))), Field('p_nome', requires= IS_NOT_EMPTY()), Field('nascimento', 'date', requires = IS_EMPTY_OR( IS_DATE( format='%Y-%m-%d'))), Field('escolaridade', requires = IS_IN_SET(['Básico','Secundário','Licenciatura','Mestrado'])) ) db.define_table( 'prod', Field('r_id', db.r ), Field('codigo', 'integer',label='Espécie', requires= IS_NOT_EMPTY()), Field('cmr_convenc', 'integer',label='Convencional', requires= IS_NOT_EMPTY()), Field('cmr_mpb', 'integer',label='M.P.Biológico',requires= IS_NOT_EMPTY()) ) -- CONTROLLER - def index(): session.forget() session.r_id = 40 # Initial value -- will be replaced by form.vars.id form = SQLFORM( db.r) if form.process( next=URL('f_prod') ).accepted: session.r_id = form.vars.id response.flash = 'Success (R_ID=%s)' % session.r_id elif form.errors: response.flash = 'ERRORS in the form' else: response.flash = 'Form 1 of 2' return dict( form=form) def f_prod(): RID = session.r_id form = SQLFORM( db.prod) if form.process().accepted: response.flash = 'Success' elif form.errors: response.flash = 'ERRORS' else: response.flash = 'Form 2 of 2' return dict( form=form, RID=RID) - What's wrong? Thanks Luis --