Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save salesforceBen/1c62d497d3629c74c4ec726a7f21ef16 to your computer and use it in GitHub Desktop.
Save salesforceBen/1c62d497d3629c74c4ec726a7f21ef16 to your computer and use it in GitHub Desktop.
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