See the answer at 
https://groups.google.com/d/msg/web2py/i01tO7LQVYE/APWn-NPoCAAJ.

The only difference is you need to conditionally set the values to True or 
False depending on which button was clicked. Assuming the approve/reject 
filtered buttons are your 5th and 6th buttons, respectively, it would be 
something like:

        if 'submit_4' in request.post_vars or 'submit_5' in request.
post_vars:
            myboolean = 'submit_4' in request.post_vars # True if 
"approved" was clicked, else False.
            db(grid_query & search_query).update(myboolean=myboolean)

Anthony

On Wednesday, December 14, 2016 at 12:40:56 AM UTC-5, Madhavi wrote:
>
> Hi,
>
> The code I am using is as below - I have 'Approve Selected Corporates', 
> 'Reject Selected Corporates', 'Approve All Corporates' and 'Reject All 
> Corporates' buttons working in the selectable list. I am changing 
> corp_approved boolean column to True or False as per the button on which 
> user clicks. I want to add 'Approve Filtered Corporates' and 'Reject 
> Filtered Corporates' buttons to this which will change the status of only 
> those records which are displayed on applying the search functionality. 
> Please let me know how this can be done:
>
> @auth.requires_login()
> def ps_corpapproval():
>     request_id = 10
>     i = 1
>     def approve_corp(ids):
>         if not ids:
>             response.flash = 'Please select a corporate to approve'
>         else:
>             for row in ids:
>                 db(db.ps_corporate_list.id == row).update(corp_approved = 
> True)
>         return ''
>     def reject_corp(ids):
>         if not ids:
>                 response.flash = 'Please select a corporate to reject'
>         else:
>             for row in ids:
>                 db(db.ps_corporate_list.id == row).update(corp_approved = 
> False)
>         return ''
>     def approve_all(ids):
>         db((db.ps_corporate_list.request_id == request_id) & 
> (db.ps_corporate_list.merchant_id == i)).update(corp_approved = True)
>         return ''
>     def reject_all(ids):
>         db((db.ps_corporate_list.request_id == request_id) & 
> (db.ps_corporate_list.merchant_id == i)).update(corp_approved = False)
>         return ''
>     corp_form = 
> SQLFORM.grid((db.ps_corporate_list.request_id==request_id)&(db.ps_corporate_list.merchant_id==i),
>  
> deletable = False, create = False, editable = False, csv = False, paginate 
> = False, selectable = [('Approve Selected Corporates', lambda ids: 
> approve_corp(ids)),('Reject Selected Corporates', lambda ids: 
> reject_corp(ids)), ('Approve All Corporates', lambda ids: 
> approve_all(ids)), ('Reject All Corporates', lambda ids: reject_all(ids))], 
> orderby = ~db.ps_corporate_list.spends, maxtextlength = 200)
>     return dict(corp_form = corp_form)
>
> Thanks,
> Madhavi
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to