Add datatables tools to ticket reports

This commit is contained in:
James Polley 2017-10-04 20:37:07 +11:00
parent 64f9b3fb6c
commit 45512e815a
4 changed files with 62 additions and 28 deletions

View file

@ -18,23 +18,52 @@
<hr />
{% for report in reports %}
<h3>{{ report.title }}</h3>
<table class="table table-striped">
<tr>
{% for heading in report.headings %}
<th>{{ heading }}</th>
{% endfor %}
</tr>
{% for line in report.rows %}
<tr>
{% for item in line %}
<td>
{{ item|safe }}
</td>
<h3>{{ report.title }}</h3>
<table class="table table-striped table-reportdata">
<thead>
<tr>
{% for heading in report.headings %}
<th>{{ heading }}</th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for line in report.rows %}
<tr>
{% for item in line %}
<td>
{{ item|safe }}
</td>
{% endfor %}
</tr>
{% endfor %}
</tr>
{% endfor %}
</table>
</tbody>
</table>
{% endfor %}
{% endblock %}
{% block extra_script %}
<script src="{{ STATIC_URL }}datatables/js/jquery.dataTables.min.js" type="text/javascript"></script>
<script src="{{ STATIC_URL }}tabletools/js/TableTools.min.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 type="text/javascript">
$(function() {
$("table.table-reportdata").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>>",
"sPaginationType": "bootstrap",
"aLengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
"bStateSave": true,
"oTableTools": {
"aButtons": [
"copy",
"csv",
"print"
],
"sSwfPath": "{{ STATIC_URL }}tabletools/swf/copy_csv_xls.swf"
}
});
});
</script>
{% endblock %}

View file

@ -80,6 +80,7 @@
"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",
"bStateSave": true,
"aLengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
"oTableTools": {
"aButtons": [
"copy",

View file

@ -108,19 +108,19 @@
<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 type="text/javascript">
$(function() {
$(".tip").tooltip();
$("table.table-reviews").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>>",
$("table.table-reportdata").each(function () {
$(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>>",
"sPaginationType": "bootstrap",
"bStateSave": true,
"aLengthMenu": [[10, 50, 100, -1], [10, 50, 100, "All"]],
"oTableTools": {
"aButtons": [
"copy",
"csv",
"print"
],
"sSwfPath": "{{ STATIC_URL }}tabletools/swf/copy_csv_xls.swf"
"aButtons": [
"copy",
"csv",
"print"
],
"sSwfPath": "{{ STATIC_URL }}tabletools/swf/copy_csv_xls.swf"
}
});
});

View file

@ -34,12 +34,15 @@
<h3 class="panel-title">{{ report.title }}</h3>
</div>
<table class="table table-striped">
<table class="table table-striped table-reportdata">
<thead>
<tr>
{% for heading in report.headings %}
<th>{{ heading }}</th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for line in report.rows %}
<tr>
{% for item in line %}
@ -48,7 +51,8 @@
</td>
{% endfor %}
</tr>
{% endfor %}
{% endfor %}
</tbody>
</table>
</div>