How to export innerHTML Values only
How to export innerHTML Values only
There is something that I was working on and I needed to export everything in CSV. I was working on AJAX loading. Here is the data part:
{ data: 'id },
{ data: 'mode' },
{ data: 'name' },
I then put a Serial number with:
{ data:'id',
"fnCreatedCell":(nTd, sData, oData, iRow, iCol)=>{
$(nTd).html(iRow+1)
} },
This far everything is okay. But With button plugin when I try to export a CSV It is not giving me Serial Number. It is giving me those ID numbers from database and they are not in serial. What I want is:
1,2,3,4,5,6,7.....
And it is giving me
23,45,46,47,50....... In CSV
How can I get the normal Serial Number in CSV file after export?
Answers
Yeah, it's because you're updating the HTML directly, so DataTables doesn't know anything about it. It would be best to create the index column with
columns.render
, that way the data is 'officially' in DataTables' domain - something like this: http://live.datatables.net/xopohelu/1/editColin