If I use A instead of button then its calling perfectly but i have to show Delete as a button not as a link. Second observation: if I am adding Delete button/link beside Search and Clear button, and if I click Query input field, its not showing query filling fields(drop down menu,conditional fields, New,Close buttons etc...) And third point is : suppose I want to pass the selected query to function "test", how can I do that?
On Tue, Nov 20, 2012 at 2:32 PM, Niphlod <niph...@gmail.com> wrote: > whoopsy, did you try with a simple A instead of a button ? > TAG.a('Delete',_id="px-**delete",_type="button",_href=U**RL('test')) > > > On Tuesday, November 20, 2012 6:27:18 AM UTC+1, Amit wrote: >> >> Thanks Niphold for sharing the example code, but still it is not working >> means upon clicking on the "Delete" button, it's not calling the test >> function, Please see below the code: >> >> >> def status(): >> grid = SQLFORM.grid(db.status) >> grid[0][1][1].components = [ >> TAG.button('Delete',_id="px-**delete",_type="button",_href=U**RL( >> 'test')) >> ] >> return locals() >> >> def test(): >> db().select(db.status.id>0).de**lete() >> db.commit() >> redirect(URL('status')) >> >> And screenshot of the status page with Delete button: >> >> >> >> Please help me to find out what wrong I am doing in the code. >> >> >> >> >> On Monday, 19 November 2012 20:48:49 UTC+5:30, Niphlod wrote: >>> >>> all the records ? >>> if you need to execurte your "test()" function you just need the browser >>> to "go" to that page. Let's assume that in your controller you have >>> >>> def index(): >>> grid = grid(db.testtable) >>> grid[0][1][1].components = [ >>> TAG.button('testbutton', _id="px-delete",_type="button"**,_href= >>> URL('test')) >>> ] >>> >>> def test(): >>> # delete all records of db.testtable >>> db(db.testtable.id>0).delete() >>> redirect(URL('index')) >>> >>> >>> Assuming that: >>> - you go to myapp/default/index and see the grid with the button >>> (assuming the code fragment you posted works for adding a button, didn't >>> test it). >>> - press that button >>> - the browser will go to the page myapp/default/test (the button was a >>> normal link) >>> - web2py will delete the table >>> - and you'll be redirected back to your (now empty) grid. >>> >>> Is it clear ? Is this what you want to achieve ? >>> >>> -- > > > > --