Moved drawing the users datatable out of the addTarget method for faster rendering of a large number of imported records.

pull/414/merge
Jordan Wright 2016-11-18 22:16:32 -06:00
parent 43cbc1d65f
commit b10ac627af
1 changed files with 10 additions and 6 deletions

View File

@ -100,6 +100,7 @@ function edit(idx) {
record.email,
record.position);
});
targets.DataTable().draw();
}
})
}
@ -128,19 +129,21 @@ function addTarget(firstNameInput, lastNameInput, emailInput, positionInput) {
// Check table to see if email already exists.
var targetsTable = targets.DataTable();
var existingRowIndex = targetsTable
.column(2, {order: "index"}) // Email column has index of 2
.column(2, {
order: "index"
}) // Email column has index of 2
.data()
.indexOf(email);
// Update or add new row as necessary.
if (existingRowIndex >= 0) {
targetsTable
.row(existingRowIndex, {order: "index"})
.row(existingRowIndex, {
order: "index"
})
.data(newRow);
} else {
targetsTable.row.add(newRow);
}
targetsTable.draw();
}
function load() {
@ -202,6 +205,7 @@ $(document).ready(function() {
$("#lastName").val(),
$("#email").val(),
$("#position").val());
targets.DataTable().draw();
// Reset user input.
$("#targetForm>div>input").val('');