I am using the same template and example which exists in sqlalchemy Datatable sample in: http://sqlalchemy-datatables.readthedocs.org/en/latest/ my code is the following, my problem is invalid json, that I could not find any problems in it. any helps? The output of rowTable.output_result() is:
{'aaData': [{'1': 'DOC - 1457715381', '0': '60352794'}, {'1': 'DOC - 1457715381', '0': '2768077336'}, {'1': 'DOC - 1457715381', '0': '6247239243'}, {'1': 'DOC - 1457715381', '0': '8257884017'}, {'1': 'DOC - 1457715381', '0': '8508822379'}], 'iTotalRecords': '5', 'sEcho': '1', 'iTotalDisplayRecords': '5'}
ERROR: DataTables warning: table id=mytable - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1
MAKO:
@view_config(route_name='doclist', request_method='GET', renderer='service:/templates/partials/doclist.mako', permission = 'login')
def viewListDocuments(self):
r = self.r
creator_id = 18
columns = []
columns.append(ColumnDT('doccode'))
columns.append(ColumnDT('doctitle'))
query = DBSession.query(Document).filter(Document.creator_id == creator_id)
rowTable = DataTables(r.GET, Document, query, columns)
return rowTable.output_result()
HTML PAGE:
<table id="mytable">
<thead>
<tr>
<th>
doccode
</th>
<th>
doctitle
</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$('#mytable').dataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "${request.route_path('doclist')}"
});
});