Export data to Json
Export data to Json

Hello,
excuse me for my english, i translated the text via google
I wanted to share with you my discovery about exporting
data from a table to JSon
The original code does not allow to have a valid Json code
because it contains the data of the header, the footer and the html icons
in table cells
while searching for a long time, I came across this link
https://github.com/lightswitch05/table-to-json
it is very easy to use
for the button code i used it like this
{
text: 'JSON',
action: function ( e, dt, button, config ) {
var table = $('#menuTable').tableToJSON({
ignoreColumns: [7]
});
$.fn.dataTable.fileSave(
new Blob( [ JSON.stringify(table,null,'\t') ] ),
'Export.json'
)
}
},
Macmicro
Replies
Hi Macmicro,
Many thanks for sharing this with us. There is also an example showing how to se JSON export here: https://datatables.net/extensions/buttons/examples/html5/customFile.html .
Regards,
Allan