###### to db.py added
db.define_table('mytable',Field('myfield','string'))
###### controllers/default.py
def index():
"""
example action using the internationalization operator T and flash
rendered by views/default/index.html or views/generic.html
"""
onclick =
XML( "ajax('"+str(URL(r=request,f='loadlist.load',args=[]))+"',
['test'], 'content');return false;" )
linkdiv=DIV(DIV(A('show me',_href='#',
_onclick=onclick)),DIV(_id='content'))
return dict(linkdiv=linkdiv)
def loadlist():
return dict()
def list():
result = []
for i in db(db.mytable.id > 0).select():
onclick=XML( "jQuery('#form"+str(i.id)
+"').slideToggle();return false;" )
form=crud.update(db.mytable,i.id,onaccept=crud.archive,deletable=False)
result.append(DIV(DIV(A(XML(i.myfield),_href='#',_onclick=onclick)),
DIV(form,_id = 'form'+str(i.id),_class = 'hidden')))
return dict(results=result)
########## views/default/list.load
{{response.headers['Content-Type']='text/
html';response.headers['web2py-response-flash']=response.flash}}
<table>
{{for result in results:}}{{ =TR(TD(result))}}{{pass}}
</table>
########## views/default/loadlist.load
{{response.headers['Content-Type']='text/
html';response.headers['web2py-response-flash']=response.flash}}
{{=LOAD ('default','list.load',args=[],ajax=True)}}
-----
Adding to mytables some strings to see the list of them in example
code.
Clicking on 'show me' give a list of table rows.
Clicking on any of row shows form for string update.
But if you submit changes, they does not reflect in list of items (but
the same time db table row was updated)
Next time submit updates the list of items was made last time.
Question: how to make update of db table before updating list of item
of the same table?
On 23 авг, 08:19, mdipierro <[email protected]> wrote:
> I think I need more explanation, a practical example of usage and an
> example of code. I do not understand.