Issue too obvious,

In function definition, select goes before crud.update, so before new
data updated old data selected.

Thank you.

    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(db.mytable[i.id].myfield),_href='#',_onclick=onclick)),

## db.mytable[i.id].myfield - force to reread data from table.
# two days of brain breaking :)
On 24 авг, 21:30, KMax <[email protected]> wrote:
> I am glad you writing poems, but it is not the wall for comments :)
> This is for issue invetigation.
>
> On 24 авг, 07:33, KMax <[email protected]> wrote:
>
>
>
> > This is link to examplehttp://web2py.ru/test
> > Click on 'show me' then on any in link of list and update. Second
> > update will reflect changes in first time
> > On 23 авг, 11:52, KMax <[email protected]> wrote:
>
> > > ###### 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.

Reply via email to