SItuar a row to the beginning of a dataTable always [closed]

0

Good morning my people I would like to know if they have any example of how to put a row always at the beginning of a table made with the dataTable plugin and looked for several ways but I can not help it please?

    
asked by Memo Marcos 18.05.2017 в 00:11
source

1 answer

1

The correct way to add a new row in datatable is:

dt_Empleados.row.add([
    "123",
    "Juan Pérez",
    "Administrativo"
]).draw();

This will add the row to the position corresponding to the current order of the table. Try to make your datatable statement something like this:

var dt_Empleados = $('#empleados').DataTable({
    "sDom": "... ...",
    "autoWidth": true,
    ...
    "order": [[1, 'asc']]
});

Look ... with the "D" in uppercase, not dataTable.

Regarding putting the row in first position, try this:

dt_Empleados.Rows.InsertAt(myDataRow, 0);
    
answered by 18.05.2017 / 03:03
source