is it possible to add a row to the beginning of the table?

is it possible to add a row to the beginning of the table?

drfunkdrfunk Posts: 58Questions: 8Answers: 0

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 17,759Questions: 25Answers: 4,216

    the order of the rows is dependent on the order of the table. This blog presents a solution to place rows at the top or bottom of the table.

    Kevin

  • drfunkdrfunk Posts: 58Questions: 8Answers: 0

    here is my code snippet:
    $(document).ready(function() {
    var t = $('#ncs').DataTable();

    $('#addRow').on( 'click', function () {
        t.row.add( [
            'John',
            'Doe'
        ] ).draw( true );
    
    } );
    

    } );

    where would I put position=top

  • kthorngrenkthorngren Posts: 17,759Questions: 25Answers: 4,216
    Answer ✓

    Put it before the Datatables init code, just like the examples. In your case it looks like before var t = $('#ncs').DataTable(); would be the correct place.

    Kevin

Sign In or Register to comment.