Column filtering question

Column filtering question

artart Posts: 19Questions: 0Answers: 0
edited March 2012 in General
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]

Replies

  • artart Posts: 19Questions: 0Answers: 0
    If I may, I would like to give this a bumb :)
  • allanallan Posts: 63,810Questions: 1Answers: 10,516 Site admin
    Hi art,

    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
  • artart Posts: 19Questions: 0Answers: 0
    edited April 2012
    OK that is still not working. If you type in '220', it will show results on the 4th column. Again my purpose is to only search in the first column which would be '0' in aTargets.

    The code at the moment is the following:
    [code]
    "aoColumnDefs": [
    { "bSearchable": false, "aTargets": [ 1, 2, 3, 4 ] }
    ],
    [/code]
  • allanallan Posts: 63,810Questions: 1Answers: 10,516 Site admin
    Ah! I missed the fact that you are using server-side processing. It looks like you are using my server-side processing script, which should cope with this - can you confirm what script you are using? If you search the code in it, does it check for bSearchable in the where condition?

    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
  • artart Posts: 19Questions: 0Answers: 0
    edited April 2012
    Yes I'm on server-side. I removed the whole pipeline code but it won't trigger bsearchable on the choosen columns. I put the pipeline back as it runs slower in pagination without it. I'm glad it's not the pipeline interfering as the pipeline is necessary for speed.

    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]
  • allanallan Posts: 63,810Questions: 1Answers: 10,516 Site admin
    edited April 2012
    Hi,

    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
This discussion has been closed.