Created
February 29, 2020 12:30
-
-
Save salesforceBen/1c62d497d3629c74c4ec726a7f21ef16 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sendAccountNames(cellData) { | |
Visualforce.remoting.Manager.invokeAction( | |
CSVParser.insertAccounts(cellData, | |
function(result, event) { | |
console.log('@@@ result is: ' + result); | |
console.log('@@@ event is: ' + event); | |
})); | |
} | |
var cellData = []; | |
function buildTable(results){ | |
var markup = "<table class='table'>"; | |
var data = results.data; | |
for(i=0;i<data.length-1;i++){ | |
markup+= "<tr>"; | |
var row = data[i]; | |
var cells = row.join(",").split(","); | |
console.log('The row is: ' + row); | |
cellData.push(row); | |
for(j=0;j<cells.length;j++){ | |
markup+= "<td>"; | |
console.log(cells[j]); | |
markup+= cells[j]; | |
markup+= "</th>"; | |
} | |
markup+= "</tr>"; | |
} | |
markup+= "</table>"; | |
sendAccountNames(cellData); | |
$("#app").html(markup); | |
} | |
$(document).ready(function(){ | |
$('#submit').on("click",function(e){ | |
e.preventDefault(); | |
if (!$('#files')[0].files.length){ | |
alert("Please choose at least one file to read the data."); | |
} | |
$('#files').parse({ | |
config: { | |
delimiter: "auto", | |
complete: buildTable, | |
}, | |
before: function(file, inputElem) | |
{ | |
console.log("Parsing file...", file); | |
}, | |
error: function(err, file) | |
{ | |
console.log("ERROR:", err, file); | |
}, | |
complete: function() | |
{ | |
console.log("Done with all files"); | |
} | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment