When only a single record is selected, in your sale_order_detail_checkout 
function, request.vars.ids will just be a single number (represented as a 
string) rather than a list. Because strings are iterable, when you iterate 
over the string representation of a multi-digit number, you end up getting 
each individual digit. In other words, you code is equivalent to:

for id in '98':

To fix it, you can change your return line to:

    return dict(ids = ids if isinstance(ids, list) else [ids])

Anthony

On Saturday, November 29, 2014 7:53:03 AM UTC-5, 黄祥 wrote:
>
> hi,
>
> is it possible grid selectable only select 1 row?
> i've tested it but with no luck, e.g.
> *controllers/order.py*
> def sale_order_detail():
> selectable = lambda ids : redirect(URL('sale_order_detail_checkout', vars 
> = dict(ids = ids) ) )
> #selectable = lambda ids: sale_order_detail_checkout(ids)
> grid = SQLFORM.grid(db.sale_order_detail, user_signature = False, 
> selectable = selectable)
> return locals()
> # sale_order_detail_checkout
> def sale_order_detail_checkout():
> ids = request.vars.ids
> return dict(ids = ids)
>
> *views/order/sale_order_detail_checkout.html*
> {{extend 'layout.html'}}
>
> {{=SPAN(ids)}}
>
> <table class="table table-condensed table-hover">
>     <tr>
>         <th>{{=T('Product') }}</th>
>         <th>{{=T('ID') }}</th>
>     </tr>
> {{for id in ids:}}
> {{detail = db(db.sale_order_detail.id == id).select().first()}}
>     <tr>
>         <td>{{=SPAN(detail.product.model.model)}}</td>
>         <td>{{=SPAN(id)}}</td> 
>     </tr>
> {{pass}}
> </table>
>
> *Result*
> No Error Occured, but the result is not expected. e.g. if i select 
> multiple row it works fine, but when i select only one row (id : 98), the 
> result show the content of id : 9 and id : 8
>
> any idea how to solve this?
>
> thanks and best regards,
>

-- 
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