Server Side Processing from CSV
Server Side Processing from CSV
Hi,
This is a great plugin and I've managed to get this working brilliantly using a JOSN formatted data source, but what would be ace is to get this working from a CSV file, I've done a fair bit of search and the only luck I've had is with this post (http://datatables.net/forums/discussion/comment/12756#Comment_12756) that was brought up a couple of years ago.
But I can't figure out how he is implementing this and how he is then calling the CSV file. I would very much appreciate any help or guidance someone can give me in getting this to work.
Many Thanks
Harry
This is a great plugin and I've managed to get this working brilliantly using a JOSN formatted data source, but what would be ace is to get this working from a CSV file, I've done a fair bit of search and the only luck I've had is with this post (http://datatables.net/forums/discussion/comment/12756#Comment_12756) that was brought up a couple of years ago.
But I can't figure out how he is implementing this and how he is then calling the CSV file. I would very much appreciate any help or guidance someone can give me in getting this to work.
Many Thanks
Harry
This discussion has been closed.
Replies
Allan
I first added a CSV file to the DOM in a table using the csv2table plugin.
[code]$("#ID").csv2table('CSVSource.csv');[/code]
However to get this to work I had to modify the original plugin to add in a section and to remove all unnecessary styling.
Next set dataTables to read directly from the DOM table.
[code]
setTimeout(function() {
$('#ID table').dataTable( {
"fnDrawCallback": function(){$('#ID').animate({opacity:1})}
});
},200);
[/code]
Adding a setTimeout is needed as it allows the csv2table to finish, I think csv2table does have an on complete callback but I haven't looked into it yet.
Thanks
Harry
There is an onload function in csv2table so the setTimeout is no longer needed.
[code]
$("#ID").csv2table('CSVSource.csv',{
onload : function(){Initialise dataTable here}
});
[/code]
Allan