If you benefit from web2py hope you feel encouraged to pay it forward by contributing back to society in whatever form you choose!


  • 0
    ammz  14 years ago
    Hi, mr.freeze I have a litle problem, with web2py 1.81.5 and webgrid(2010-07-09) I can do this In Model
    db.define_table("pagos",
        Field("nota", 'integer', requires=IS_NOT_EMPTY(error_message='No puede estar vacio'), label='No. de Nota'),
        Field("pago", "double", requires=IS_NOT_EMPTY(error_message='No puede estar vacio')),
        Field("saldo", "double", default=0,writable=False),
        Field("vendedor",db.vendedores, requires=IS_IN_DB(vendedores,'vendedores.id','%(names)s %(apelPater)s %(apelMater)s')),
        Field('entregado','boolean', default=False),
        Field('entregadoEl', 'datetime', default=request.now, label='Entregado el'),
        Field("observaciones","string"))
    
    
    In Controller
    @auth.requires_membership('Capturista')
    def lee_entregas():
        Capturista = db(db.capturistas.creadoPor==auth.user.id).select()[0]
        db.pagos.vendedor.represent = lambda vendedores: vendedores.names
        grid = webgrid.WebGrid(crud)
        grid.datasource = db((db.pagos.vendedor==db.vendedores.id)&(db.vendedores.regional_id==Capturista.regional_id))
        grid.pagesize = 50
        grid.enabled_rows = ['header','filter','pager','footer']
        grid.fields = ['pagos.nota','pagos.pago','pagos.saldo','pagos.entregadoEl','pagos.vendedor']
        grid.field_headers = ['Nota','Pago','Saldo','Entregado','Vendedor']
    
        grid.crud_function = 'data' # Set the function where crud will be exposed.
        grid.action_links = ['view']
        grid.action_headers = ['Ver']
    
        grid.filters = ['pagos.nota']
        grid.filter_items_query = lambda field: (db.pagos.vendedor==db.vendedores.id)&(db.vendedores.regional_id==Capturista.regional_id)
    
        grid.view_link= lambda row: A('view', _href= crud.url(f='show_entrega', args=[row['pagos']['id']]))
    
        crud.settings.controller = 'entregas'
    
        return dict(gridpag=grid())
    
    
    But with web2py 1.81.5 and webgrid(2010-07-26), I get error in this line grid.view_link= lambda row: A('view', _href= crud.url(f='show_entrega', args=[row['pagos']['id']])) Can I do something to avoid that error?

Commented on:

This is a module that lets you build a table on the server that supports paging, sorting, editing and totals easily. It requires no javascript or sessions to work.

Hosting graciously provided by:
Python Anywhere