Table does not refresh data after quick search - server side
Table does not refresh data after quick search - server side
hectorc
Posts: 2Questions: 1Answers: 0
I'm searching data using Server Side, but the table does not refresh, even if it is receiving a json response.
This is the response from the request after the search:
{
"draw": 1,
"recordsTotal": 2,
"recordsFiltered": 1,
"data": [
{
"account_id": "1",
"names": "nombre",
"primary_last_name": "Appat",
"second_last_name": "Apmat",
"rut": "18.245.354-6",
"active": "1",
"sex": "1",
"applications": false
}
]
}
The table shows the processing message, but not show the new data.
This is the table after search:
This is the DataTable's config:
var table = $('#js-postulants-table').DataTable({
ajax: {
url: main_base_url + "admin/postulants/getAllPostulants",
type:"POST"
},
serverSide: true,
processing: true,
dom: 'Blfrtip',
"searching": true,
'columns': [
{'data': 'account_id'},
{'data': 'names'},
{'data': 'primary_last_name'},
{'data': 'second_last_name'},
{'data': 'rut'},
{'data': 'applications',
render: function (data, type, row, meta){
if (data === false) {return "???"}
return data;
}
},
{'data': 'active'},
{'data': 'sex',
render: function (data, type, row, meta){
if (data === "1") {return "M"} else {return "F"}
}
},
{'data': null,
render: function (data, type, row, meta){
var attributes = {
btnType: "button",
btnClass: "btn btn-default btn-xs",
btnId: "",
url: main_base_url + "admin/postulants/edit/" + data.account_id,
aTarget: "_blank",
iClass: "fa fa-edit",
label: ""
}
return printActionButton(attributes);
}
}
],
columnDefs: [
{ className: "text-center", "targets": "_all" },
{ orderable: false, targets: [5,6] }
],
language: {
url: main_base_url+"assets/plugins/datatables/dataTables.spanish.txt"
}
});
There is no error on browser's console
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi @hectorc ,
I see in your example, you have
"draw": 1
, when the table has been filtered at least once. Is that value incrementing with each transaction, because I would've expected that to be at least 2 (the second draw for the filter)?Cheers,
Colin
Thank you so much @colin. That was my error.