whoopsy, did you try with a simple A instead of a button ?
TAG.a('Delete',_id="px-delete",_type="button",_href=URL('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=URL('test'
> ))
> ]
> return locals()
>
> def test():
> db().select(db.status.id>0).delete()
> 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 ?
>>
>>
--