jQWidgets Forums

Forum Replies Created

Viewing 1 post (of 1 total)
  • Author
    Posts

  • John
    Participant

    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.

Viewing 1 post (of 1 total)