How to re-fill dataTable on text change
How to re-fill dataTable on text change
Fandry Noutah
Posts: 1Questions: 1Answers: 0
Hello everyone, I have my dataTable filled with ajax from another PHP page (json encoded).
And I want to add a select box near the entries filter to filter my dataTable.
So how can I re-fill the dataTable when my own selectBox change?
I tried this but it's not working
$(document).ready(function(){
var dataTable = $('#student_table').DataTable({
"processing": true,
"serverSide": true,
"order": [],
"ajax": {
url: 'student_action.php',
type: 'POST',
data: {action: 'fetch'}
},
"columnDefs": [{
"targets": [0,1,2,3,4,5],
"orderable": false
}]
});
$('#promo_filter').change(function(){
$('#student_table').DataTable({
"processing": true,
"serverSide": true,
"order": [],
"ajax": {
url: 'student_action.php',
type: 'POST',
data: {id_promotion:$(this).val()}
},
"columnDefs": [{
"targets": [0,1,2,3,4,5],
"orderable": false
}]
});
});
});
thanks
This discussion has been closed.
Answers
You would need to destroy the original table first, either with
destroy()
ordestroy
.If that doesn't help, we're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Colin