Here is my code:
<script type="text/javascript">
$(document).ready(function() {
var oTable = $('#search_table').dataTable( {
"sDom": 'T<"clear">lrtip',
"oTableTools": {
"sSwfPath": "{% static "extras/copy_csv_xls_pdf.swf" %}",
"aButtons": [ "csv", "pdf", "print" ]
},
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "{% url 'search_list_json' %}",
"aaSorting": [ [2,'asc'], [1,'desc'] ],
// Disable sorting for the Actions column.
"aoColumnDefs": [ { "bSortable": false, "aTargets": [ 0,4 ] } ]
} );
} );
</script>
Strangely, if comment-out "bServerSide": true", it works fine and my table is displayed nicely in HTML. but when I have it, I get `aData is undefined` error. what is the problem here and how to fix it?
The JSON object returned from server seems fine as per the format. it has aaData
{"result": "ok", "iTotalRecords": 1, "aaData": [["<center><a href=\"/search/1\"><font color=\"red\">Mazda=>626:2012-1986</font></a>\n </center>", "04/07/2014", "10000", "1000", "<center><a href='/search/update/1/'><img src='/static/images/icons/icon_changelink.gif'></a> <a href='/search/delete/1/'><img src='/static/images/icons/icon_deletelink.gif'></a></center>"]], "sEcho": 0, "iTotalDisplayRecords": 1}
Thanks
<script type="text/javascript">
$(document).ready(function() {
var oTable = $('#search_table').dataTable( {
"sDom": 'T<"clear">lrtip',
"oTableTools": {
"sSwfPath": "{% static "extras/copy_csv_xls_pdf.swf" %}",
"aButtons": [ "csv", "pdf", "print" ]
},
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "{% url 'search_list_json' %}",
"aaSorting": [ [2,'asc'], [1,'desc'] ],
// Disable sorting for the Actions column.
"aoColumnDefs": [ { "bSortable": false, "aTargets": [ 0,4 ] } ]
} );
} );
</script>
Strangely, if comment-out "bServerSide": true", it works fine and my table is displayed nicely in HTML. but when I have it, I get `aData is undefined` error. what is the problem here and how to fix it?
The JSON object returned from server seems fine as per the format. it has aaData
{"result": "ok", "iTotalRecords": 1, "aaData": [["<center><a href=\"/search/1\"><font color=\"red\">Mazda=>626:2012-1986</font></a>\n </center>", "04/07/2014", "10000", "1000", "<center><a href='/search/update/1/'><img src='/static/images/icons/icon_changelink.gif'></a> <a href='/search/delete/1/'><img src='/static/images/icons/icon_deletelink.gif'></a></center>"]], "sEcho": 0, "iTotalDisplayRecords": 1}
Thanks