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?
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?
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);