Create multiple blank rows

Create multiple blank rows

karliekarlie Posts: 83Questions: 17Answers: 0

Hi, I have created a button that creates a new row, without Editor appearing, and it works fine:

//Create Empty  
        new $.fn.dataTable.Buttons(table, [{
            extend: "create",
            text: "Create Empty Row",
            action: function(e, dt, node, config) {
                editor.create(false).submit();
            }
        }]);

        table
            .buttons().container().appendTo($('#createempty'));

How might I go about extending this so that I can create 5 blank rows with one button click? Can I create multiple actions with the above code?

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,144Questions: 26Answers: 4,736
    Answer ✓

    I haven't tried it but it looks like there is a parameter count for create() that should work. Take a look at the second to the last example.
    https://editor.datatables.net/reference/api/create()

    Kevin

  • karliekarlie Posts: 83Questions: 17Answers: 0

    Brilliant, thanks Kevin (a case of RTFM!) Here's the code if it's useful for anybody

    //Create Empty  
            new $.fn.dataTable.Buttons(table, [{
                extend: "create",
                text: "Create Empty Row",
                action: function(e, dt, node, config) {
                    editor.create(5,false).submit();
                }
            }]);
    
            table
                .buttons().container().appendTo($('#createempty'));
    
This discussion has been closed.