Problem with ajax and language
Problem with ajax and language
mstraczkowski
Posts: 2Questions: 1Answers: 0
Hello,
I've noticed a problem when im using language and ajax server-side processing:
Below example works correctly for me:
<script type="text/javascript">
$(function() {
// Loading datatables
$('.datatables').dataTable({
"iDisplayLength": 50,
"dom": 'Bfrtip',
"stateSave": true,
"processing": true,
"serverSide": true,
"ajax": {
"url": "/index.php/employees/datatable",
"type": "POST"
},
"buttons": [
'excel', 'pdf'
],
"columns": [
{ "data": "e.id_employee" },
{ "data": "e.firstname" },
{ "data": "e.lastname" },
{ "data": "e.email" }
]
}).columnFilter();
});
</script>
But when I add language parameter it stops working. I mean datatables is trying to send data to current URL (GET /employees) - instead of POST to /employees/datatable.
Below example doesn't work for me:
<script type="text/javascript">
$(function() {
// Loading datatables
$('.datatables').dataTable({
"iDisplayLength": 50,
"dom": 'Bfrtip',
"stateSave": true,
"processing": true,
"serverSide": true,
"ajax": {
"url": "/index.php/employees/datatable",
"type": "POST"
},
"buttons": [
'excel', 'pdf'
],
"language": {
"url": "/public/js/datatables.pl.json"
},
"columns": [
{ "data": "e.id_employee" },
{ "data": "e.firstname" },
{ "data": "e.lastname" },
{ "data": "e.email" }
]
}).columnFilter();
});
</script>
May somebody explain me what am I doing wrong? or what is happenning?
Thanks in advance
This discussion has been closed.
Answers
Well, there is something wrong with columnFilter plugin
I think you are correct - the columnFilter plug-in (which is third party, and as far as I am aware, no longer being updated by its author) doesn't support the async initialisation that is caused by the use of the
language.url
option.You would need to initialise the plug-in in
initComplete
.Allan