trying your suggestion with datatables that have web2py multiple table 
relations join
*ref:*
http://www.web2pyslices.com/slice/show/2052/using-datatablesnet-with-web2py-for-ultra-fast-grid-display

*models/db.py*
db.define_table('sale_order', Field('sale_order_no') )
db.define_table('cash_in', Field('cash_in_no'), Field('sale_order_no', 
'reference sale_order') )
db.define_table('cash_out', Field('cash_out_no'), Field('sale_order_no', 
'reference sale_order') )
if db(db.sale_order).isempty():
    db.sale_order.update_or_insert(sale_order_no = 'SO1')
    db.cash_in.update_or_insert(cash_in_no = 'CI1', sale_order_no = 1)
    db.cash_in.update_or_insert(cash_in_no = 'CI2', sale_order_no = 1)
    db.cash_out.update_or_insert(cash_out_no = 'CO1', sale_order_no = 1)
    db.cash_out.update_or_insert(cash_out_no = 'CO2', sale_order_no = 1)

*controllers/default.py*
def index():
    import json
    #query = ((db.cash_in.sale_order_no == db.sale_order.id) | 
(db.cash_out.sale_order_no == db.sale_order.id) )
    #rows = db(query).select().as_list()
    #left = [db.cash_in.on(db.sale_order.id == db.cash_in.sale_order_no), 
db.cash_out.on(db.sale_order.id == db.cash_out.sale_order_no) ]
    left = db.cash_in.on(db.sale_order.id == db.cash_in.sale_order_no)
    rows = db().select(db.sale_order.ALL, db.cash_in.ALL, left = left)
    people = json.dumps(rows)
    return dict(results = XML(people) )

*views/default/index.html*
{{extend 'layout.html'}}
<script 
src="https://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js";></script>
<link rel="stylesheet" media="screen" 
href="https://cdn.datatables.net/1.10.15/css/jquery.dataTables.min.css";>
<table id="person-table" class="table table-bordered table-striped" 
cellspacing="0" width="100%">
    <thead>
        <tr>
            <th>Sale Order No</th>
            <th>Cash In No</th>
            <th>Cash Out No</th>
        </tr>
    </thead>
</table>
<script>
$(document).ready(function(){
    $("#person-table").DataTable({
        data:  {{=results}},
        columns: [
            { data: 'sale_order.sale_order_no' },
            { data: 'cash_in.cash_in_no' },
            { data: 'cash_out.cash_out_no' }
        ]
    })
});
</script>

*Return an error traceback*
Traceback (most recent call last):
  File "/Users/MacBookPro/site/web2py/gluon/restricted.py", line 219, in 
restricted
    exec(ccode, environment)
  File 
"/Users/MacBookPro/site/web2py/applications/a/controllers/default.py", line 
60, in <module>
  File "/Users/MacBookPro/site/web2py/gluon/globals.py", line 409, in 
<lambda>
    self._caller = lambda f: f()
  File 
"/Users/MacBookPro/site/web2py/applications/a/controllers/default.py", line 
19, in index
    people = json.dumps(rows)
  File 
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py",
 
line 243, in dumps
    return _default_encoder.encode(obj)
  File 
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py",
 
line 207, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File 
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py",
 
line 270, in iterencode
    return _iterencode(o, 0)
  File 
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py",
 
line 184, in default
    raise TypeError(repr(o) + " is not JSON serializable")
TypeError: <Rows (2)> is not JSON serializable

is it possible to pass dal join rows result into json format in web2py?

thanks and best regards,
stifan

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to