Problem with bSearchable boolean

Problem with bSearchable boolean

mikamika Posts: 2Questions: 0Answers: 0
edited February 2011 in General
Hi,

I use Datatables 1.7.5 and everything works so far... except one thing: the "bSearchable" boolean. When I try to disable filtering on a column (with boolean set to false) it does nothing, I can still filter it.

This is strange because the "bVisible" boolean works perfectly ! So If somebody knows why or what is wrong in my code, please let me know :)

[code]
$(document).ready(function() {
$('#table-members').dataTable( {
"aaSorting": [[1, 'asc']],
"bJQueryUI": true,
"bProcessing": false,
"bServerSide": true,
"bStateSave": false,
"bAutoWidth": false,
"iDisplayLength": 50,
"sPaginationType": "full_numbers",
"sAjaxSource": "app/members/list.php",
"aoColumns": [
{"bVisible": true, "bSearchable": false},
{"bVisible": true, "bSearchable": true, "sWidth": "25%"},
{"bVisible": true, "bSearchable": false},
{"bVisible": true, "bSearchable": true, "sWidth": "20%"},
{"bVisible": true, "bSearchable": false},
{"bVisible": true, "bSearchable": true, "sWidth": "10%", "sClass": "center"},
{"bVisible": true, "bSearchable": true, "sWidth": "10%", "sClass": "center"},
{"bVisible": true, "bSearchable": true, "sWidth": "10%", "sClass": "center"},
{"bVisible": true, "bSearchable": false},
{"bVisible": true, "bSearchable": true, "sWidth": "20%"},
{"bVisible": true, "bSearchable": true, "sWidth": "5%","sClass": "center"}
]
} );
} );
[/code]

It's the default configuration from server side filtering :

[code]
/* Filtering */
$sWhere = "";
if ($_GET['sSearch'] != "")
{
$sWhere = "WHERE (";
for ($i=0; $i

Replies

  • mikamika Posts: 2Questions: 0Answers: 0
    Ok I have found a solution :

    [code]
    /* Filtering */
    $sWhere = "";
    if ( $_GET['sSearch'] != "" )
    {
    $sWhere = "WHERE engine LIKE '%".mysql_real_escape_string( $_GET['sSearch'] )."%' OR ".
    "browser LIKE '%".mysql_real_escape_string( $_GET['sSearch'] )."%' OR ".
    "platform LIKE '%".mysql_real_escape_string( $_GET['sSearch'] )."%' OR ".
    "version LIKE '%".mysql_real_escape_string( $_GET['sSearch'] )."%' OR ".
    "grade LIKE '%".mysql_real_escape_string( $_GET['sSearch'] )."%'";
    }
    [/code]
  • JosephJoseph Posts: 9Questions: 0Answers: 0
    edited December 2011
    Hi !
    I'm using DataTables 1.8.2, and I've found this solution :

    [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
    */

    if ( $_GET['sSearch'] != "" )
    {
    $sWhere .= "AND (";
    for ( $i=0 ; $i
  • Eric_DeCoffEric_DeCoff Posts: 8Questions: 0Answers: 0
    Had to add trim to get it working correctly, also added handling for all column not searchable

    $sWhere = "";
    if ( isset($_GET['sSearch']) && $_GET['sSearch'] != "" )
    {
    $sWhere = "WHERE (";
    for ( $i=0 ; $i
This discussion has been closed.