0
Personal how can I make a form submission, a Datatable is created and populated with the result of the filter made in the form and make Datatable do server-side paging.
Datatable Version: 1.9.4
The first part of creating Datatable and popular with the result is working like this:
var table = $('#exemplo').DataTable({
processing: true,
serverSide: true
});
$('#enviar').click(function(event) {
var formData = $('form[name="form-teste"]').serialize();
$.ajax({
url: 'consulta.php',
method: 'GET',
data: formData + '&action=consulta',
cache: false,
dataType: 'json',
beforeSend: function()
{
table.fnClearTable();
}
}).done(function(data)
{
table.fnAddData(data.data);
}).fail(function(error)
{
console.log('error');
});
});
JSON is like this:
{
"draw":0,
"recordsTotal":2,
"recordsFiltered":2,
"data":
[
[
"teste 1",
"3232132",
"237",
"123",
"456",
"joao",
"1000.00",
"300.00",
"62079786768",
null
],
[
"teste 2",
"33323",
"237",
"123",
"456",
"joao",
"1000.00",
"300.00",
"62079786768",
null
]
]
}
Now the server-side paging part is that I can’t find a solution
Look at this - Datatables Pagination with parameters
– Edilson
Didn’t help at all @Edilson but Valew just like that man
– smigol
It’s basically what you’re looking for. Enter the code you’re currently using for your query.
– Edilson
But this mine already does, I am looking now is a solution for server-side paging
– smigol
But the pagination part is also there.
– Edilson
Hello. I also searched a lot and would like to know how to do it. However, I found an excellent solution in the link below. https://coderexample.com/datatable-scroller-server-side/ Best wishes.
– Nuno Figueiredo