Serverside-Processing & AJAX - Select filter not works
Serverside-Processing & AJAX - Select filter not works
vertisan
Posts: 7Questions: 2Answers: 0
Hi!
I need to implement filter by select input to my table. I using serverside-processing to get data from DB and AJAX for dynamic actions.
Pagination, entries and search works fine but only this filter not, why?
Here is my code:
$(document).ready(function() {
table = $('#VolunteersList').DataTable({
searching: true,
"processing": true,
"serverSide": true,
"order": [],
"ajax": {
"url": "<?php echo site_url('wolontariat/przegladaj')?>",
"type": "POST"
},
"language": {
"url": "<?php echo site_url('assets/js/dataTables.Polish-lang.json') ?>"
},
"lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "Wszystko"]],
"columnDefs": [
{
"targets": [ -1, 0, -2 ],
"orderable": false,
},
],
"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
nRow.className = aData[0 /* or whatever */] == "94" ? "HighlightUser" : "";
// USTAWIĆ ZWRACANIE HIGHLIGHT Z BAZY
return nRow;
},
});
});
setInterval( function () {
reload_table();
}, 5000 );
function reload_table() {
table.ajax.reload(null,false);
}
}
This discussion has been closed.
Answers
Thanks for your question - however, per the forum rules can you link to a test case showing the issue please. This will allow the issue to be debugged.
Information on how to create a test page], if you can't provide a link to your own page can be found here.
Thanks,
Allan
Ofc, here is website, where is implemented DataTables and where is problem.
http://demo.vrs-factory.pl/DT/
If is needed PHP Code - tell me.
The client is sending the following to the server for the column search:
Is your server-side processing script configured to accept regular expressions? I suspect not and that is the issue.
I would suggest, at least in the first instance, that you drop the regular expressions - I doubt you need it with server-side processing.
Allan
Here is my PHP code (I using CodeIgniter)
Controller (creating array for DataTables)
http://pastebin.com/wq7s9XqH
Model (getting data from DB)
http://pastebin.com/SU32GmFF
REF
I'm afraid I don't support custom server-side code, but on a quick scan it looks like it isn't configured to support regular expressions. Either you need to change your server-side code to accept regular expressions (and the performance penalty that comes with that in SQL) or you need to not send a regular expression to the server-side.
Allan
hey @vertisan, you solve the problem??? i want do the same thing in my proyect
i found the way how to do this on
http://coderexample.com/datatable-custom-column-search/
but i must specify what column i want to have custom search one by one in model and view :x
and this still show first page data only
on my view im using initcomplete
my controller
http://pastebin.com/LRuNHYbv
my model
http://pastebin.com/XtaKDTMG
just add this code above if($_POST['search']['value']) to get request from datatable based on selected column at "this.api().columns([1])"
the example result
https://goo.gl/photos/EMN3NhWNiYHSQNRz7