I'm using JQuery Datatables buttons for presenting the data on my page (as it has functions for items like Copy to Clipboard /Export to CSV / Print. Then, for the retrieval of data from the server, I'm using angular js.
The issue is that the data rendered from angular ng-repeat won't appear when invoking datatable buttons like copy/csv/print/etc, but these items appeared just fine on the page. But for the static dummy data that I have included, it is being processed by the buttons.
Below are the code snippets:
excerpt from page:
<table id="datatable-buttons" class="table table-striped table-bordered ng-cloak">
<thead>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Job</th>
<th>Location</th>
<th>Age</th>
<th>Date Hired</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<tr>
<td>Donna</td>
<td>Snider</td>
<td>Customer Support</td>
<td>New York</td>
<td>27</td>
<td>2011/01/25</td>
<td>[email protected]</td>
</tr>
<tr ng-repeat="person in persons">
<td>{{person.fname}}</td>
<td>{{person.lname}}</td>
<td>{{person.job}}</td>
<td>{{person.location}}</td>
<td>{{person.age}}</td>
<td>{{person.date_hired}}</td>
<td>
<div ng-show="person.email == null">N/A</div>
<div ng-show="person.email != null">{{person.email}}</div>
</td>
</tr>
</tbody>
</table>
...
<script>
$(document).ready(function() {
var handleDataTableButtons = function() {
if ($("#datatable-buttons").length) {
$("#datatable-buttons").DataTable({
dom: "Bfrtip",
buttons: [
{
extend: "copy",
className: "btn-sm"
},
{
extend: "csv",
className: "btn-sm"
},
{
extend: "excel",
className: "btn-sm"
},
{
extend: "pdfHtml5",
className: "btn-sm"
},
{
extend: "print",
className: "btn-sm"
},
],
responsive: true
});
}
};
TableManageButtons = function() {
"use strict";
return {
init: function() {
handleDataTableButtons();
}
};
}();
$('#datatable').dataTable();
$('#datatable-keytable').DataTable({
keys: true
});
$('#datatable-responsive').DataTable();
// $('#datatable-scroller').DataTable({
// ajax: "js/datatables/json/scroller-demo.json",
// deferRender: true,
// scrollY: 380,
// scrollCollapse: true,
// scroller: true
// });
$('#datatable-fixed-header').DataTable({
fixedHeader: true
});
var $datatable = $('#datatable-checkbox');
$datatable.dataTable({
'order': [[ 1, 'asc' ]],
'columnDefs': [
{ orderable: false, targets: [0] }
]
});
$datatable.on('draw.dt', function() {
$('input').iCheck({
checkboxClass: 'icheckbox_flat-green'
});
});
TableManageButtons.init();
});
</script>
Any help would be appreciated. TIA