bSearchable issue

bSearchable issue

pakypaky Posts: 106Questions: 0Answers: 0
edited April 2012 in DataTables 1.9
Why my columnDefs are false on bSearchable param and my dtable continue to search on that columns ? Thanks

Replies

  • koosvdkolkkoosvdkolk Posts: 169Questions: 0Answers: 0
    Could you put your code on http://live.datatables.net/#javascript,html,live?
  • pakypaky Posts: 106Questions: 0Answers: 0
    It's a server side php code :(
  • pakypaky Posts: 106Questions: 0Answers: 0
    Can I post a screenshot of my Datatables debug output ?
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Ah - if you are using server-side processing, then until about two days ago my demo script didn't actually take the bSearchable flag into account for the global filter... An update to the script is available here: http://datatables.net/development/server-side/php_mysql

    Allan
  • pakypaky Posts: 106Questions: 0Answers: 0
    mmm.... this is my code:
    [code]
    /*
    * Filtering
    * NOTE this does not match the built-in DataTables filtering which does it
    * word by word on any field. It's possible to do here, but concerned about efficiency
    * on very large tables, and MySQL's regex functionality is very limited
    */
    $sWhere = "";
    if (isset($_GET['sSearch']) && $_GET['sSearch'] != "") {
    $sWhere = "WHERE (";
    for ($i = 0; $i < count($aColumns); $i++) {
    /*
    * Qui salto il where sul settimo campo
    * (DATE_FORMAT((DATE_ADD(MAX(tbl_progetto.presa_in_carico_data),INTERVAL 12 DAY)),'%d-%M-%Y'))
    *
    */

    if($i!=7)
    {
    $sWhere .= $aColumns[$i] . " LIKE '%" . mysql_escape_string($_GET['sSearch']) . "%' OR ";
    }
    }
    $sWhere = substr_replace($sWhere, "", -3);
    $sWhere .= ')';
    }


    /* Individual column filtering */
    for ($i = 0; $i < count($aColumns); $i++) {
    if (isset($_GET['bSearchable_' . $i]) && $_GET['bSearchable_' . $i] == "true" && $_GET['sSearch_' . $i] != '') {
    if ($sWhere == "") {
    $sWhere = "WHERE ";
    } else {
    $sWhere .= " AND ";
    }
    $sWhere .= $aColumns[$i] . " LIKE '%" . mysql_escape_string($_GET['sSearch_' . $i]) . "%' ";
    }
    }
    [/code]
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Yeah, around like 11 you need a check on $_GET['bSearchable_' . $i] a bit like what is on line 29 (although without the sSearch_{i} check obviously :-)

    Allan
  • pakypaky Posts: 106Questions: 0Answers: 0
    Want to understand that the "sSearch" I don'tt need to anything? I can comment it?
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Have a look at line 92 in the example I linked to before: http://datatables.net/development/server-side/php_mysql - that is what is missing from the code you pasted before.

    Allan
  • pakypaky Posts: 106Questions: 0Answers: 0
    right ;)
This discussion has been closed.