Column filtering question
Column filtering question
I would like to disable filtering on columns 3,4 and 5. I am applying the following code but it hasn't disabled filtering in those columns so far. Is this code correct?
[code]
"aoColumnDefs": [
{ "bSearchable": false, "aTargets": [ 3, 4, 5 ] }
],
[/code]
[code]
"aoColumnDefs": [
{ "bSearchable": false, "aTargets": [ 3, 4, 5 ] }
],
[/code]
This discussion has been closed.
Replies
The thing to remember here is that the column indexes given in aTargets are array indexes which start from 0, not 1. So if you want to disable filtering on columns 3, 4 and 5, you need to give aTargets as [ 2, 3, 4 ]! At the moment you are telling DataTables that there are six columns in the table (due to the '5' in the array) which is causing a Javascript error to occur. I believe if you change the indexes, then it will spring into life :-)
Regards,
Allan
The code at the moment is the following:
[code]
"aoColumnDefs": [
{ "bSearchable": false, "aTargets": [ 1, 2, 3, 4 ] }
],
[/code]
I wonder if it is possible that the pipelining is "getting in the way" - if you disable that, does it work as you would expect (it looks like it should - which is why I suspect the server-side script here).
Regards,
Allan
The code looks like this:
[code]
$(document).ready(function() {
$('#example').dataTable( {
"aoColumnDefs": [
{ "bSearchable": false, "aTargets": [ 1, 2, 3, 4 ] }
],
"bProcessing": true,
"bServerSide": true,
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"sAjaxSource": "scripts/server_processing.php",
"oLanguage": {
"sProcessing": "Hetkinen...",
"sLengthMenu": "Näytä kerralla _MENU_ veropäätöstä",
"sZeroRecords": "Tietoja ei löytynyt",
"sInfo": "Näytetään päätökset _START_ - _END_ (yhteensä _TOTAL_ )",
"sInfoEmpty": "Näytetään 0 - 0 (yhteensä 0)",
"sInfoFiltered": "(suodatettu _MAX_ tuloksen joukosta)",
"sInfoPostFix": "",
"sSearch": "Merkki ja malli:",
"sUrl": "",
"oPaginate": {
"sFirst": "Ensimmäinen",
"sPrevious": "Edellinen",
"sNext": "Seuraava",
"sLast": "Viimeinen"
}
}
} );
} );
[/code]
Thanks for the feedback - with this I've realised that the error is in my server-side processing script. The bSearchable flag is checked for the individual column filters, but it isn't checked for the global filter being applied to the columns. I've just committed the required change to git, and updated my script here: http://datatables.net/development/server-side/php_mysql - the change is in lines 92 - 95.
Thanks for flagging this up!
Regards,
Allan