Open patrickaglibut opened 6 years ago
Are you sure that you get only the first page? datatable.all(true)
should return everything, even filtered data.
Yes Sir, only the viewable data. Unless I change the pageSize to say 20 then that is the only time i can get all the record.
Btw I'm using jquery 1.12 and here's the code i use to extract the data.
$(document).on('click','#btnextract', function() { var datatable = new DataTable(document.getElementById('MyTable'), { identify: 'id' }); var savedData = datatable.all(true); console.log(savedData); });
I cannot reproduce... If you go to this page: http://holt59.github.io/datatable/ and type datatable.all(true)
in the console, you'll get 29 entries, whatever the current filters are on the example table.
Could you add more details regarding your code?
here's the html file i used using your sample table. Thanks for checking on this Sir.
On your site when I tested what you have instructed, the datatable.all(true) extracts all data even though it is already filtered wherein it should only be 7 records.
Yes, this is the expected behavior currently, but it's different from having a single page.
In your code, you create a new DataTable
to extract the data, this is not correct (you should never have two datatables on the same table). You should simple use the existing one:
$('#first-datatable-output table').datatable('select', true):
I see, so the .all feature will extract data regardless of the filters used. Thanks for noting this and I'll try to create a function to extract only the filtered result. Any pointers would be very helpful. Thanks again.
You can use the filterIndex
attribute:
// Retrieve the datatable object from the element.
var dt = $('#first-datatable-output table')[0].datatable;
// Retrieve filtered data
var filteredData = [];
for (var i = 0; i < dt.filterIndex.length; ++i) {
filteredData.push(dt.data[dt.filterIndex[i]]);
}
Not tested, but you get the idea.
Noted and Thanks
I reopen this to keep it on the TODO list.
Good Day Sir,
Is there a way to extract all the table record, after filtering, etc, including the other paginated data?
Currently when using the datatable.all(true) option will only return the viewable part of the table but not the other data. Hoping for your response. Thanks.
Based on the screenshot below, I can only extract page 1 but i also need to extract pages 2 - 4.