Filtering with "multiple select" with multiple table

Filtering with "multiple select" with multiple table

martoofmartoof Posts: 32Questions: 0Answers: 0
edited May 2011 in General
Hello everyone, I'm french and I need your help.

I want to have 3 tables on the same page and a "multiple select" to filtering one column on my tables (for example : column "engine version").
I call my table on my database like this :
[code]
TABLE 1
CAMERA



Browser
Plateform
Engine version
CSS grade




<?php
$sql_variable = $bdd->query("SELECT * FROM my_table");
//----------------------------------------------------------------
while ($variable = $sql_variable->fetch())
{
?>

<?php echo $variable['browser']; ?>
<?php echo $variable['plateform']; ?>
<?php echo $variable['engine_version']; ?>
<?php echo $variable['css_grade']; ?>

<?php
}
//----------------------------------------------------------------
$sql_variable->closeCursor();
?>



[/code]

I would like this : http://dl.dropbox.com/u/21672921/table.jpg

Can you give me an example which work ? :)
Thank you ! and sorry for my english...

Replies

  • martoofmartoof Posts: 32Questions: 0Answers: 0
    Up !
    Please this is important and I am very interested in this post.
    Thanks
  • allanallan Posts: 63,252Questions: 1Answers: 10,420 Site admin
    Have a look at this plug-in which should help: http://datatables.net/plug-ins/api#fnFilterAll

    Allan
  • martoofmartoof Posts: 32Questions: 0Answers: 0
    thank you allan ! I will do my best in june, and if I have a problem I re-post here!
  • martoofmartoof Posts: 32Questions: 0Answers: 0
    I'm already back!
    I do not understand how to work fnfilterAll to filter a single column for all tables.
    I am inspired by this, I think this is very close to what I want to do : http://datatables.net/examples/api/regex.html
    I would have exactly this page but, with several tables, the filteringAll enter in conflict with the column filtering ...
    I await your suggestions!
    Thanks
  • allanallan Posts: 63,252Questions: 1Answers: 10,420 Site admin
    edited May 2011
    [code]
    oTable.fnFilterAll( "filter_value", columnIndex /*i.e. 2 or 3 etc */, false );
    [/code]
    where oTable is the DataTables instance.

    Allan
  • martoofmartoof Posts: 32Questions: 0Answers: 0
    edited May 2011
    This doesn't work...
    I try with an input before doing it with a select, but "filter_value" is not good :

    [code]
    /* copy and paste : I did not understand this function */
    $.fn.dataTableExt.oApi.fnFilterAll = function(oSettings, sInput, iColumn, bEscapeRegex) {
    for (var i in this.dataTableSettings) {
    jQuery.fn.dataTableExt.iApiIndex = i;
    this.fnFilter(sInput, iColumn, bEscapeRegex);
    }
    }


    $(document).ready(function() {
    $("#filter_col3").keyup( function ()
    {
    $(".table_a_filtrer").dataTable().fnFilterAll(this.value,3,false); /* 'this.value' doesn't work... ? */
    } );
    [/code]

    Thank you for your time allan !
  • allanallan Posts: 63,252Questions: 1Answers: 10,420 Site admin
    In what way does 'this.value' not work? If you add console.log( this.value ); does t not give you the value of the text input? Also you probably want keypress rather than keyup.

    Allan
  • martoofmartoof Posts: 32Questions: 0Answers: 0
    edited May 2011
    I'm sorry allan but this doesn't work ! ^^
    Maybe there is an conflict with my display ?
    This is all my code, if you find a big error... thank you very much :)

    [code]
    $.fn.dataTableExt.oApi.fnFilterAll = function(oSettings, sInput, iColumn, bEscapeRegex) {
    for (var i in this.dataTableSettings) {
    jQuery.fn.dataTableExt.iApiIndex = i;
    this.fnFilter(sInput, iColumn, bEscapeRegex);
    }
    }

    $(document).ready(function()
    {

    /* Filtre g
  • martoofmartoof Posts: 32Questions: 0Answers: 0
    YOUPI !!!
    It's ok, thank you very much allan !
    My problem is my "id" :in html I have "col3_filter" and in jquery I have "filter_col3" !

    I am ashamed^^

    I will now try to convert this input to select MULTIPLE...
    I certainly need help, this is not the first time that I asked this question on this forum.
    Anyway, I go to the next step!
    thank you
  • martoofmartoof Posts: 32Questions: 0Answers: 0
    edited May 2011
    Can you help me again ?
    I can not find answers on the internet.

    [code]
    $("#col5_filter").change( function ()
    {
    $("select[id='col5_filter'] option:selected").each(function() {
    /*here*/
    });

    $(".table_a_filtrer").dataTable().fnFilterAll(/* and here*/,4,false);
    } );
    [/code]

    What should I put in this code in order to have something like this:

    [code]
    $('#example').dataTable().fnFilter( 'option1|option2|...|optionN ',columnNo,false);
    [/code]

    -----------------------------------
    Pending a response, I continued searching and I try to understand how to read array directly jquery because I think that in php, I want something like this :
    [code]
    foreach($col5_filter[] as $test)
    {
    $condition = $condition.(($marqueur==0) ? $test : ' | '.$test);
    $marqueur++;
    }
    [/code]
    if you do not understand php code, ignore it!
    -----------------------------------

    Thanks
This discussion has been closed.