link to a grid

46 views
Skip to first unread message

Andrea Fae'

unread,
May 10, 2018, 6:59:45 AM5/10/18
to web...@googlegroups.com
Hello I have a grid with certain fields.
In a filed there is a name of a pdf file that I have in the folder "static/Etichette". I have a lot of pdf file in this folder and I'd like, when I click this link, to open the related file...

This is the grid
grid = SQLFORM.grid(db.socio, links = [lambda row: A('Etichetta', _href=URL('static/Etichette', args=[row.etichetta]))], details=False, create=False, editable=False, deletable=False, maxtextlength=40)

or

    grid = SQLFORM.grid(db.socio, links = [lambda row: A('Etichetta', _href=URL("static/Etichette/%s" % row.etichetta))], details=False, create=False, editable=False, deletable=False, maxtextlength=40)


This is the table

db.define_table('socio',
                Field('codice', type='integer', requires=[IS_NOT_EMPTY()]),
                Field('cognome', requires=[IS_NOT_EMPTY()]),
                Field('nome', requires=[IS_NOT_EMPTY()]),
                Field('intestazione', requires=[IS_NOT_EMPTY()]),
                Field('dnascita', requires=[IS_NOT_EMPTY()]),
                Field('indirizzo', requires=[IS_NOT_EMPTY()]),
                Field('cap', requires=[IS_NOT_EMPTY()]),
                Field('comune', requires=[IS_NOT_EMPTY()]),
                Field('provincia', requires=[IS_NOT_EMPTY()]),
                Field('telefono', requires=[IS_NOT_EMPTY()]),
                Field('codfisc', requires=[IS_NOT_EMPTY()]),
                Field('etichetta'),
                auth.signature,singular="Socio",plural="Soci",migrate='socio.table',
                format='%(intestazione)s')

How can I do?

I have this error

invalid function (default/static)


Yes...I know that there is something wrong but I don't know in this moment what...

Richard Vézina

unread,
May 10, 2018, 9:27:57 AM5/10/18
to web2py-users
The error message is simple, you don't have a controller function named static in you default controller file...

Richard

On Thu, May 10, 2018 at 6:59 AM, Andrea Fae' <and...@gmail.com> wrote:
Hello I have a grid with certain fields.
In a filed there is a name of a pdf file that I have in the folder "static/Etichette". I have a lot of pdf file in this folder and I'd like, when I click this link, to open the related file...

This is the grid
grid = SQLFORM.grid(db.socio, links = [lambda row: A('Etichetta', _href=URL('static/Etichette', args=[row.etichetta]))], details=False, create=False, editable=False, deletable=False, maxtextlength=40)


This is the table

db.define_table('socio',
                Field('codice', type='integer', requires=[IS_NOT_EMPTY()]),
                Field('cognome', requires=[IS_NOT_EMPTY()]),
                Field('nome', requires=[IS_NOT_EMPTY()]),
                Field('intestazione', requires=[IS_NOT_EMPTY()]),
                Field('dnascita', requires=[IS_NOT_EMPTY()]),
                Field('indirizzo', requires=[IS_NOT_EMPTY()]),
                Field('cap', requires=[IS_NOT_EMPTY()]),
                Field('comune', requires=[IS_NOT_EMPTY()]),
                Field('provincia', requires=[IS_NOT_EMPTY()]),
                Field('telefono', requires=[IS_NOT_EMPTY()]),
                Field('codfisc', requires=[IS_NOT_EMPTY()]),
                Field('etichetta'),
                auth.signature,singular="Socio",plural="Soci",migrate='socio.table',
                format='%(intestazione)s')

How can I do?

I have this error

invalid function (default/static)


Yes...I know that there is something wrong but I don't know in this moment what...

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Anthony

unread,
May 10, 2018, 8:06:26 PM5/10/18
to web2py-users
The signature of the URL function is URL(a, c, f). If you pass only two arguments, it assumes they are c and f, and if you pass only one, it assumes it is f. You passed only 'static/Etichette', so it assumes that is the function and therefore uses the current application and controller. It should instead be:

URL('static', 'Etichette', args=[row.etichetta])

'static' is a special value for the controller.

Anthony

Andrea Fae'

unread,
May 11, 2018, 1:12:27 PM5/11/18
to web2py-users
...I'm sorry...it was written in the book!! Sorry...I need to read again some parts of the book! Thank you
Reply all
Reply to author
Forward
0 new messages