I know it’s been a while, but maybe that’s still useful to someone:
From what I understand, yours $("#mytable").dataTable({paging: false});
does not recognise the new lines included - this is how it needs to be. When you work with Data Table the changes are made in a similar way to a "Dataset", that is: you make a copy of the data, change what you need in this copy and then save your changes in the definitive table.
To include new lines the easiest way is to use an object that contains an attribute for each column of your table. Also, whenever you add new lines you will need to redesign the table (using ". draw()" - datatable.draw()) for the new data to be rendered and appear on the screen.
Example:
Consider a table called "myTable" with the fields name, Cpf and Civil state. This way create a client object with these attributes:
To add this object to the data table we have to use a function similar to this:
function addRowsDataTable(cliente){
//criando o "data set" - captura todos os dados da DataTable original e inclui eles na variavel dTable (é um array de objetos)
dTable = $('#myTable').DataTable();
//incluindo o objeto cliente
dTable.rows.add(
[{
"nome" : cliente.nome, //0
"cpf" : cliente.cpf, //2
"estadoCivil" : cliente.estadoCivil
}]
);
//renderizando novamente a dataTable com os novos dados.
dTable.draw();
}
NOTE: remember that in your HTML page you need to include the data table references:
<script type="text/javascript" charset="utf8" src="/DataTables/datatables.js"></script>
and also:
<link rel="stylesheet" type="text/css" href="/DataTables/datatables.css">
How to do?
Call the function addRowsDataTable and pass as parameter an object client with the necessary attributes. The function will add a line with the client data and render the table again.
What function are you using to insert the rows ?
– Pedro Henrique