cnizzardini / cakephp-datatable

CakePHP Component for interoperability between CakePHP 2.x and jQuery DataTables plugin.
62 stars 49 forks source link

Individual column filtering #7

Open walliby opened 10 years ago

walliby commented 10 years ago

This may be more of a general datatables question but I am not finding any resolution in the datatables docs. I am not having any luck getting individual column filtering to work.

This works to filter the whole table... $('select#association').change( function() { oTable.fnFilter( $(this).val()); } );

But this does not work to filter only my 2nd column... $('select#association').change( function() { oTable.fnFilter( $(this).val(), 1); } );

cnizzardini commented 10 years ago

Try asking the datatables forum: https://datatables.net/forums/

walliby commented 10 years ago

Following up on the individual column filtering, I had to add any $_GET['sSearch_colnum'] to my paginate conditions. Any thoughts on adding support for individual column filtering in the component? Below is how datatables implemented it in straight PHP...

/* 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_real_escape_string($_GET['sSearch_'.$i])."%' ";
    }
}
cnizzardini commented 10 years ago

Will do at some point. Feel free to add it yourself and if it works I can add it into the code.