ich diese django HTML-Vorlage habe mit der Nutzung von Datentabellen Tabelle:Csv Schaltfläche erscheint nicht in Datentabellen
{% extends "base.html" %}
{% load dictionary_extras %}
{% block title %}QA reports - {{report_title}}{% endblock %}
{% block content %}
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.12/css/jquery.dataTables.min.css"/>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.2.3.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>
<style type="text/css">
tfoot {
display: table-header-group;
}
</style>
<h1>{{report_title}}<br>
<small>(created on: {{report_creation_time}})</small>
</h1>
<table id='report_data' class="display" cellspacing="0" width="100%">
<thead>
<tr>
{% for col_name in report_data_headers%}
<th>{{col_name}}</th>
{% endfor %}
</tr>
</thead>
<tfoot>
<tr>
{% for col_name in report_data_headers%}
<th>{{col_name}}</th>
{% endfor %}
</tr>
</tfoot>
<tbody>
{% for data_row in report_data%}
<tr>
{% for item in data_row%}
<td>{{item}}</td>
{% endfor%}
</tr>
{% endfor %}
</tbody>
</table>
<script>$(document).ready(function() {
// Setup - add a text input to each footer cell
$('#report_data tfoot th').each(function() {
var title = $(this).text();
$(this).html('<input type="text" placeholder="Search '+title+'" />');
});
// DataTable
var table = $('#report_data').DataTable({
"aLengthMenu": [[20, 50, 100, -1],
[20, 50, 100, "All"]],
"buttons": ['csv']
});
// Apply the search
table.columns().every(function() {
var that = this;
$('input', this.footer()).on('keyup change', function() {
if (that.search() !== this.value) {
that
.search(this.value)
.draw();
}
});
});
});
</script>
{% endblock %}
Ich folge diesen datatables tutorial
Mein Problem ist, dass ich nicht die Datentabellen machen CSV-Schaltfläche erscheint auf der Seite. Ich frage nach dieser Option in "buttons": ['csv']
Zeile. Versucht verschiedene Optionen mit und ohne Anführungszeichen ohne Glück - die Datentabelle wird angezeigt, als ob die "Schaltflächen" -Zeile nicht im Code vorhanden ist. Gibt es ein Syntaxproblem mit meinem Code?
Die Tasten werden nicht meine Magie erscheinen. Sie müssen mindestens den Quellcode des Buttons plugin einfügen und dataTables anweisen, Schaltflächen entweder über die Option 'dom' oder über eine Schaltflächeninstanz zu verwenden. – davidkonrad