Make datatable work for each table on the page, not just the first

This commit is contained in:
James Polley 2017-10-05 00:55:30 +11:00
parent 8f28a444a2
commit 8aa1148f7a

View file

@ -49,12 +49,12 @@
<script src="{{ STATIC_URL }}datatables/js/dataTables.bootstrap.js" type="text/javascript"></script> <script src="{{ STATIC_URL }}datatables/js/dataTables.bootstrap.js" type="text/javascript"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/ace/1.2.0/ace.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/ace/1.2.0/ace.js"></script>
<script type="text/javascript"> <script type="text/javascript">
$(function() { $("table.table-reportdata").each(function () {
$("table.table-reportdata").dataTable({ $(this).dataTable({
"sDom": "<'row'<'col-md-3'l><'col-md-3'T><'col-md-4'f>r>t<'row'<'col-md-3'i><'col-md-5'p>>", "sDom": "<'row'<'col-md-3'l><'col-md-3'T><'col-md-4'f>r>t<'row'<'col-md-3'i><'col-md-5'p>>",
"sPaginationType": "bootstrap", "sPaginationType": "bootstrap",
"aLengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
"bStateSave": true, "bStateSave": true,
"aLengthMenu": [[10, 50, 100, -1], [10, 50, 100, "All"]],
"oTableTools": { "oTableTools": {
"aButtons": [ "aButtons": [
"copy", "copy",
@ -63,7 +63,7 @@
], ],
"sSwfPath": "{{ STATIC_URL }}tabletools/swf/copy_csv_xls.swf" "sSwfPath": "{{ STATIC_URL }}tabletools/swf/copy_csv_xls.swf"
} }
}); });
}); });
</script> </script>
{% endblock %} {% endblock %}