Do you know you can do this?

db.define_table('thing',Field('name'),Field('active','boolean',default=False))

@auth.requires_login()
def index():
     grid = SQLFORM.grid(db.thing,
        inks=[lambda row: A('on' if row.active else 'off',
                                 _class='btn', _id='t%i'%row.id, 
target='t%i'%row.id,
                                 callback=URL('activate',args=row.id))])
     return dict(grid=grid)

@auth.requires_login()
def activate():
    if request.env.request_method=='POST':
        thing = db.thing(request.args(0,cast=int))
        thing.update_record(active=not thing.active)
        return 'on' if thing.active else 'off'

It makes Ajax buttons which toggle "on/off" the value of thing.active field 
for each row.

-- 

--- 
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.


Reply via email to