How do i add multiple rows in a table using .create
How do i add multiple rows in a table using .create
I want to add 15 dummy entries when i press the button with the same value. I cannot use rows.add() function as my id in database is auto incremented so it throws an error saying row id is not defined
table.button().add(
null, {
text: 'Create Entries',
action: function (e, dt, node, config) {
// Function to generate and submit a new entry
var tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);
var tomorrowFormatted = tomorrow.toISOString().slice(0, 19).replace("T", " ");
editor
.create({
title: 'Create Entry',
buttons: 'Add',
formOptions: {
main: {
onSubmit: function (e, action) {
action.submit();
}
}
}
})
.set('editdeliveredBy', 0)
.set('R.leadLRV', '52070')
.set('R.trailLrv', '52070')
.set('R.createdOn', tomorrowFormatted)
.submit();
},
});
This question has an accepted answers - jump to answer
Answers
You can optionally pass the first parameter of
create()
as a row count to make it create multiple new rows. So:would be the way to do what you are looking for.
Allan
Thanks, You're Awesome
Here is the link to the site "https://stagingc.assettrack.cx/operations/dailyRunSheet.php".
I guess you already have access to the site.