skip to Main Content

Export all rows from DataTables in excel but exported only visible rows, but i am try to export all rows that visible or hidden in the pagination – Javascript

$(document).ready(function() { $('#downloadBtn').click(function() { var table = $('.table2excel').DataTable(); var allRows = table.rows().data().toArray(); var allRowsTable = $('<table>').append($('.table2excel').find('thead').clone()).append($('<tbody>')); for (var i = 0; i < allRows.length; i++) { allRowsTable.append($('<tr>').append(allRows[i])); } allRowsTable.table2excel({ filename: 'data.xls', sheetName: 'Sheet1', exclude: '.noExl', preserveColors: true }); }); });…

VIEW QUESTION

Access to DataTable rows when table is paginated – Jquery

$(document).ready(function() { $('#example').DataTable({ select: true }); $('#btnGet').on('click', function() { const dt = $('#example').DataTable(); dt.rows((idx, data, node) => { console.log(data); }); }); }); <link href="https://cdn.datatables.net/1.13.1/css/jquery.dataTables.min.css" rel="stylesheet"> <link href="https://cdn.datatables.net/select/1.5.0/css/select.dataTables.min.css" rel="stylesheet"> <script src="https://code.jquery.com/jquery-3.5.1.js"></script> <script src="https://cdn.datatables.net/1.13.1/js/jquery.dataTables.min.js"></script> <script src="https://cdn.datatables.net/select/1.5.0/js/dataTables.select.min.js"></script> <table id="example" class="display" style="width:100%"> <thead> <tr>…

VIEW QUESTION
Back To Top
Search