jQWidgets Forums
Forum Replies Created
-
Author
-
August 12, 2015 at 6:39 pm in reply to: How to apply datatable style to my table How to apply datatable style to my table #74765
I am creating table from one csv file using this code
<!DOCTYPE html>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<title></title>
<script type=”text/javascript” src=”libs/jquery.slimscroll.min.js”></script><script type=”text/javascript”>
function Upload_file() {
var fileUpload = document.getElementById(“fileUpload”);
//var regex = /^([a-zA-Z0-9\s_\\.\-:])+(.csv|.txt)$/;
//if (regex.test(fileUpload.value.toLowerCase())) {
if (typeof (FileReader) != “undefined”) {
var reader = new FileReader();
reader.onload = function (e) {
var table = document.createElement(“table”);
var rows = e.target.result.split(“\n”);
for (var i = 0; i < rows.length; i++) {
var row = table.insertRow(-1);
if (i == 0) {
var cells = (rows[i] + “,new_column1” + “,new_column2”).split(“,”);
}
else {
var cells = rows[i].split(“,”);
}for (var j = 0; j < cells.length; j++) {
var cell = row.insertCell(-1);
cell.innerHTML = cells[j];
}
}
var div_bind = document.getElementById(“div_bind”);
div_bind.innerHTML = “”;
div_bind.appendChild(table);
}
reader.readAsText(fileUpload.files[0]);
} else {
alert(“This browser does not support HTML5.”);
}
//} else {
// alert(“Please upload a valid CSV file.”);
//}
}</script>
</head>
<body>
<table>
<tr>
<td>Select File</td>
<td><input id=”fileUpload” type=”file” accept=”.csv” /></td>
<td>
<input id=”btnloaddata” type=”button” value=”Load Data” onclick=”Upload_file()” /></td>
</tr>
<tr></tr>
</table>
<div id=”div_bind”></div>
</body>
</html>Data Easily Converting from CSV to HTML table
But
I need to apply Jqwidget Datatable Display Style to my created table. -
AuthorPosts