[web2py] How to add a column to SQLFORM.smartgrid that contains the row count?

2015-01-15 Thread César Bustíos Benites
Hello all, I have a simple SQLFORM.smartgrid using two tables: "tramites" 
and "desarrollo_tramites":


This is how the code looks like:

@auth.requires_login()
def consulta_tramite():
user_id = auth.user.id
user_area = auth.user.area
db.tramites.estado.writable = False
db.tramites_procesos.tramite.writable = False
db.tramites_procesos.usuario.default = user_id
db.tramites_procesos.usuario.writable = False
form = SQLFORM.smartgrid(
db.tramites,
linked_tables = ['tramites_procesos'],
divider=' ⇒',
fields=[
db.tramites.id,
db.tramites.tiempo,
db.tramites.documento_generado,
db.tramites_procesos.id,
db.tramites_procesos.tiempo,
db.tramites_procesos.indicacion,
db.tramites_procesos.usuario,
db.tramites_procesos.area_destino,
db.tramites_procesos.usuario_destino,
db.tramites_procesos.comentarios
],
editable=False,
deletable=False,
create=False,
details=False,
exportclasses=dict(xml=False, html=False, json=False, tsv=False, 
tsv_with_hidden_cols=False),
maxtextlength=100,
formstyle='bootstrap'
)


if form.element('.web2py_table table'):
form.element('.web2py_table table')['_class'] = 'table 
table-bordered'
for tr in form.element('.web2py_table table tbody'):
for td in tr.components:
if 'Urgente' in td.components:
td.add_class('warning warning-message')
elif 'Muy Urgente' in td.components:
td.add_class('danger danger-message')
return dict(form=form)

I want to add an extra column at the beginning of the table that shows the 
row count, something like this:

# | Nº trámite | Fecha | ...
===
1 | ...
2 | ...
3 | ...
4 | ...

How can I achieve such thing?

Thank you,
César B.

-- 
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/d/optout.


[web2py] How to add a column?

2012-11-05 Thread Bill Thayer
Can't beleive this question does not come up in the search box. How do i 
add a column to a table using SQLlite? Simply adding hte field to the 
define table statement throws an error.

Using SQLlite I cannot add a Field. I get an error message:


OperationalError: no such column: source_via.substrate


No Joke Really? 


When I set migrate_enabled=True then the message changes to something like "the 
table sourc_via does not exist"


Of course it does since I just added the column that I'm being told does not 
exist either to it.


On top of all that I am back to the Rocket server locking up. It likes to do 
that so I have to use Task manager to close it. Could be that session.connect 
+SQLlite is not a good combinnation.

--