[web2py] Re: customizating the headers of the result in crud.search
Records {{=SQLTABLE(db().select(db.person.ALL), headers='fieldname:capitalize', truncate=100, upload=URL('download')) }}
[web2py] Re: customizating the headers of the result in crud.search
IMO that is not 'wasting time', it is reporting a bug :) I am not so sure about the behaviour of 'linkto' (as discussed elsewhere), but I think there should definitely be a 'sanity check' for rows rather than a cryptic message about colnames. I wish I knew enough about SQLTABLE to suggest one. -D On Nov 5, 6:17 pm, demetrio wrote: > It seems that it's been a long day... > > {{if not rows:}} > No matches found > {{else:}} > {{=SQLTABLE(rows,headers={"field.id":"custom name id", > "field.name":"custom name"})}} > {{pass}} > > more simple... impossible... > > Sorry for wasting your time :( > > On 5 nov, 18:06, demetrio wrote: > > > I think I got excited too soon. I tried these method and it seems that > > it not works. > > > This is the traceback: > > > Traceback (most recent call last): > > File "/home/demetrio/devel/web2py_devel/trunk/devel/web2py/gluon/ > > restricted.py", line 188, in restricted > > exec ccode in environment > > File "/home/demetrio/devel/web2py_devel/trunk/devel/web2py/ > > applications/calendar/views/calendars/search.html", line 97, in > > > > File "/home/demetrio/devel/web2py_devel/trunk/devel/web2py/gluon/ > > sqlhtml.py", line 1192, in __init__ > > columns = sqlrows.colnames > > AttributeError: 'list' object has no attribute 'colnames' > > > One question, i'm using web2py Version 1.87.3. Can it be that this > > funcionality is applied on trunk or newer versions? > > > Thx again for your time. > > > On 2 nov, 16:04, demetrio wrote: > > > > Thanks a lot Massimo! > > > > On 2 nov, 14:58, mdipierro wrote: > > > > > Yes. In the view, instead of > > > > > {{=rows}} > > > > > do > > > > > {{=SQLTABLE(rows,headers=)}} > > > > > On Nov 2, 5:43 am, demetrio wrote: > > > > > > Hi, first of all sorry if I made any mistake in english :) > > > > > > When i try to make acrud.search(), i can customize the names of the > > > > > search form, but i cant do the same with the results' headers. > > > > > > def search(): > > > > > db.licenses.id.represent = lambda id: \ > > > > > DIV(A('edit',_href=URL(r=request, f='update', args=(id)))," ", > > > > > A('read',_href=URL(r=request, f='read', args=(id)))," > > > > > ",A('delete',_onclick="return confirm('" + T("Are you sure to > > > > > delete?") > > > > > +"')",_href=URL(r=request, f='delete', args=(id > > > > > form, rows =crud.search(db.licenses, field_labels = > > > > > {'id':'ID','name':'Name'}) > > > > > return dict(form=form, rows=rows) > > > > > > With this, code my form is something like: > > > > > > ID > > > > > Name > > > > > > but my results table is: > > > > > > licenses.id licenses.name > > > > > -- > > > > > edit read delete resultname1 > > > > > edit read delete resultname2 > > > > > edit read delete resultname3 > > > > > > Do you know if there is any posibility to customize that header > > > > > names?, > > > > > > it will be nice if I could use the "headers" parameter like in the > > > > >crud.search() method because you can do something like this modifying > > > > > the represent of the id > > > > > > Search Form: > > > > > **ID** > > > > > Name > > > > > > Results: > > > > > > **Actions** Name > > > > > -- > > > > > edit read delete resultname1 > > > > > edit read delete resultname2 > > > > > edit read delete resultname3 > > > > > > notice that the field licenses.id in the form is named **ID**, and in > > > > > the results is named **Actions** > > > > > > Thats all, thanks in advance :) > >
[web2py] Re: customizating the headers of the result in crud.search
It seems that it's been a long day... {{if not rows:}} No matches found {{else:}} {{=SQLTABLE(rows,headers={"field.id":"custom name id", "field.name":"custom name"})}} {{pass}} more simple... impossible... Sorry for wasting your time :( On 5 nov, 18:06, demetrio wrote: > I think I got excited too soon. I tried these method and it seems that > it not works. > > This is the traceback: > > Traceback (most recent call last): > File "/home/demetrio/devel/web2py_devel/trunk/devel/web2py/gluon/ > restricted.py", line 188, in restricted > exec ccode in environment > File "/home/demetrio/devel/web2py_devel/trunk/devel/web2py/ > applications/calendar/views/calendars/search.html", line 97, in > > File "/home/demetrio/devel/web2py_devel/trunk/devel/web2py/gluon/ > sqlhtml.py", line 1192, in __init__ > columns = sqlrows.colnames > AttributeError: 'list' object has no attribute 'colnames' > > One question, i'm using web2py Version 1.87.3. Can it be that this > funcionality is applied on trunk or newer versions? > > Thx again for your time. > > On 2 nov, 16:04, demetrio wrote: > > > Thanks a lot Massimo! > > > On 2 nov, 14:58, mdipierro wrote: > > > > Yes. In the view, instead of > > > > {{=rows}} > > > > do > > > > {{=SQLTABLE(rows,headers=)}} > > > > On Nov 2, 5:43 am, demetrio wrote: > > > > > Hi, first of all sorry if I made any mistake in english :) > > > > > When i try to make acrud.search(), i can customize the names of the > > > > search form, but i cant do the same with the results' headers. > > > > > def search(): > > > > db.licenses.id.represent = lambda id: \ > > > > DIV(A('edit',_href=URL(r=request, f='update', args=(id)))," ", > > > > A('read',_href=URL(r=request, f='read', args=(id)))," > > > > ",A('delete',_onclick="return confirm('" + T("Are you sure to delete?") > > > > +"')",_href=URL(r=request, f='delete', args=(id > > > > form, rows =crud.search(db.licenses, field_labels = > > > > {'id':'ID','name':'Name'}) > > > > return dict(form=form, rows=rows) > > > > > With this, code my form is something like: > > > > > ID > > > > Name > > > > > but my results table is: > > > > > licenses.id licenses.name > > > > -- > > > > edit read delete resultname1 > > > > edit read delete resultname2 > > > > edit read delete resultname3 > > > > > Do you know if there is any posibility to customize that header > > > > names?, > > > > > it will be nice if I could use the "headers" parameter like in the > > > >crud.search() method because you can do something like this modifying > > > > the represent of the id > > > > > Search Form: > > > > **ID** > > > > Name > > > > > Results: > > > > > **Actions** Name > > > > -- > > > > edit read delete resultname1 > > > > edit read delete resultname2 > > > > edit read delete resultname3 > > > > > notice that the field licenses.id in the form is named **ID**, and in > > > > the results is named **Actions** > > > > > Thats all, thanks in advance :) > >
[web2py] Re: customizating the headers of the result in crud.search
I think I got excited too soon. I tried these method and it seems that it not works. This is the traceback: Traceback (most recent call last): File "/home/demetrio/devel/web2py_devel/trunk/devel/web2py/gluon/ restricted.py", line 188, in restricted exec ccode in environment File "/home/demetrio/devel/web2py_devel/trunk/devel/web2py/ applications/calendar/views/calendars/search.html", line 97, in File "/home/demetrio/devel/web2py_devel/trunk/devel/web2py/gluon/ sqlhtml.py", line 1192, in __init__ columns = sqlrows.colnames AttributeError: 'list' object has no attribute 'colnames' One question, i'm using web2py Version 1.87.3. Can it be that this funcionality is applied on trunk or newer versions? Thx again for your time. On 2 nov, 16:04, demetrio wrote: > Thanks a lot Massimo! > > On 2 nov, 14:58, mdipierro wrote: > > > Yes. In the view, instead of > > > {{=rows}} > > > do > > > {{=SQLTABLE(rows,headers=)}} > > > On Nov 2, 5:43 am, demetrio wrote: > > > > Hi, first of all sorry if I made any mistake in english :) > > > > When i try to make acrud.search(), i can customize the names of the > > > search form, but i cant do the same with the results' headers. > > > > def search(): > > > db.licenses.id.represent = lambda id: \ > > > DIV(A('edit',_href=URL(r=request, f='update', args=(id)))," ", > > > A('read',_href=URL(r=request, f='read', args=(id)))," > > > ",A('delete',_onclick="return confirm('" + T("Are you sure to delete?") > > > +"')",_href=URL(r=request, f='delete', args=(id > > > form, rows =crud.search(db.licenses, field_labels = > > > {'id':'ID','name':'Name'}) > > > return dict(form=form, rows=rows) > > > > With this, code my form is something like: > > > > ID > > > Name > > > > but my results table is: > > > > licenses.id licenses.name > > > -- > > > edit read delete resultname1 > > > edit read delete resultname2 > > > edit read delete resultname3 > > > > Do you know if there is any posibility to customize that header > > > names?, > > > > it will be nice if I could use the "headers" parameter like in the > > >crud.search() method because you can do something like this modifying > > > the represent of the id > > > > Search Form: > > > **ID** > > > Name > > > > Results: > > > > **Actions** Name > > > -- > > > edit read delete resultname1 > > > edit read delete resultname2 > > > edit read delete resultname3 > > > > notice that the field licenses.id in the form is named **ID**, and in > > > the results is named **Actions** > > > > Thats all, thanks in advance :) > >
[web2py] Re: customizating the headers of the result in crud.search
Thanks a lot Massimo! On 2 nov, 14:58, mdipierro wrote: > Yes. In the view, instead of > > {{=rows}} > > do > > {{=SQLTABLE(rows,headers=)}} > > On Nov 2, 5:43 am, demetrio wrote: > > > Hi, first of all sorry if I made any mistake in english :) > > > When i try to make a crud.search(), i can customize the names of the > > search form, but i cant do the same with the results' headers. > > > def search(): > > db.licenses.id.represent = lambda id: \ > > DIV(A('edit',_href=URL(r=request, f='update', args=(id)))," ", > > A('read',_href=URL(r=request, f='read', args=(id)))," > > ",A('delete',_onclick="return confirm('" + T("Are you sure to delete?") > > +"')",_href=URL(r=request, f='delete', args=(id > > form, rows = crud.search(db.licenses, field_labels = > > {'id':'ID','name':'Name'}) > > return dict(form=form, rows=rows) > > > With this, code my form is something like: > > > ID > > Name > > > but my results table is: > > > licenses.id licenses.name > > -- > > edit read delete resultname1 > > edit read delete resultname2 > > edit read delete resultname3 > > > Do you know if there is any posibility to customize that header > > names?, > > > it will be nice if I could use the "headers" parameter like in the > > crud.search() method because you can do something like this modifying > > the represent of the id > > > Search Form: > > **ID** > > Name > > > Results: > > > **Actions** Name > > -- > > edit read delete resultname1 > > edit read delete resultname2 > > edit read delete resultname3 > > > notice that the field licenses.id in the form is named **ID**, and in > > the results is named **Actions** > > > Thats all, thanks in advance :) > >
[web2py] Re: customizating the headers of the result in crud.search
Yes. In the view, instead of {{=rows}} do {{=SQLTABLE(rows,headers=)}} On Nov 2, 5:43 am, demetrio wrote: > Hi, first of all sorry if I made any mistake in english :) > > When i try to make a crud.search(), i can customize the names of the > search form, but i cant do the same with the results' headers. > > def search(): > db.licenses.id.represent = lambda id: \ > DIV(A('edit',_href=URL(r=request, f='update', args=(id)))," ", > A('read',_href=URL(r=request, f='read', args=(id)))," > ",A('delete',_onclick="return confirm('" + T("Are you sure to delete?") > +"')",_href=URL(r=request, f='delete', args=(id > form, rows = crud.search(db.licenses, field_labels = > {'id':'ID','name':'Name'}) > return dict(form=form, rows=rows) > > With this, code my form is something like: > > ID > Name > > but my results table is: > > licenses.id licenses.name > -- > edit read delete resultname1 > edit read delete resultname2 > edit read delete resultname3 > > Do you know if there is any posibility to customize that header > names?, > > it will be nice if I could use the "headers" parameter like in the > crud.search() method because you can do something like this modifying > the represent of the id > > Search Form: > **ID** > Name > > Results: > > **Actions** Name > -- > edit read delete resultname1 > edit read delete resultname2 > edit read delete resultname3 > > notice that the field licenses.id in the form is named **ID**, and in > the results is named **Actions** > > Thats all, thanks in advance :)