Individual column searching NOT WORKING
Individual column searching NOT WORKING
Hello.
I have a problem, not working filter data by column.
I put my code:
It does not work---
var table = $('#listado').DataTable({
"bFilter": false,
"scrollX": true,
"aaSorting": [[ 0, "asc"]],
"language": {
"url": "<?php echo base_url() ?>plugins/datatables/languages/<?php echo $this->lang->lang() ?>.json"
}
});
// Apply the search
table.columns().every( function () {
var that = this;
$( 'input', this.footer() ).on( 'keyup change', function () {
that
.search( this.value )
.draw();
} );
} );
it works---
var table = $('#listado').DataTable();
// Apply the search
table.columns().every( function () {
var that = this;
$( 'input', this.footer() ).on( 'keyup change', function () {
that
.search( this.value )
.draw();
} );
You know what the problem is? please help! Thank You.
} );
Answers
Per the forum rules, can you link to a test case showing the issue in future please.
IN this case you need to put your search code into
initComplete
since you are using Ajax to load the table's data (recall what the first letter of Ajax stands for :-) ).Allan
Hello.
No use Ajax to load data in the table. The table is loaded into html / php and then run the script.
If I create an empty datatable without options if it works, if it does not work I think with options.
Yes sorry - you are using Ajax to load the language data, rather than the table data. In which case the same applies - use
initComplete
to initialise your search inputs.Allan
ok, as you would with InitComplete?
this does not work!!!
Can you link to the page so I might debug it please.
Allan
Sorry, I work on localhost, not online.
I'm afraid there is little I can do to offer any help in that case. I would need a test case showing the issue so I can debug it.
Allan