I'm using TableToolsand DataTables v1.10on the same page.
My main page has a table and an empty div for modal ones.
<div id="resultDiv">
<table id="mainTable"> ... </table>
<div id="detailModal">
<div id="detailModal-content"></div>
</div>
</div>
<script>
$(document).ready(function () {
var mainTable = $('#mainTable').DataTable({
"dom": 'T<"clear">lrtip',
"tableTools": { ... },
"columns": [
{
"data": null,
"render": function(data, type, row, meta) {
return '<a href="" onClick="return loadDetail(' + data.id + ')">Details</a>';
}
},
....
],
........
});
});
function loadDetail(id) {
$.ajax({
async: false,
url: ...,
success: function(respose) {
var tableInstance = TableTools.fnGetInstance('detailTable');
console.log(tableInstance);
}
});
}
</script>
On a separate details page, there is another table that appears in the detailModal-contentdiv.
<table id="detailTable">
</table>
<script>
$(document).ready(function () {
var mainDetailTable = $jq11('#detailTable').DataTable({
"dom": 'T<"clear">ltipr',
"tableTools": { ... },
..............
});
});
</script>
Here, the first TableToolsof mainTableworks fine, but for the second table it does not work (I can click the button, but clicking on it does not create the xls file). I am trying to solve this problem by calling fnResizeButtons()after creating the table suggested here . But tableInstanceit is null.
Any suggestion?
αƞjiβ source
share