How do i add multiple rows in a table using .create

How do i add multiple rows in a table using .create

Aryan1703Aryan1703 Posts: 65Questions: 15Answers: 1

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

Sign In or Register to comment.