Individual column filtering example

Individual column filtering example

jimvjimv Posts: 27Questions: 0Answers: 0
edited October 2009 in General
Allan,
The more I use DataTables, the more impressed I am! Thanks for taking time to create/maintain it.

Problem resolved, typo error in my code (I had 2 document ready, both including Datatables, which were conflicting with each other).

And I'm even more impressed with DataTables now!
:-)



Will individual column filtering using the below code work on data loaded from a serverside script?

$("tfoot input").keyup( function () {
/* Filter on the column (the index) of this element */
oTable.fnFilter( this.value, $("tfoot input").index(this) );
} );

I've tried to implement it, but I can't get it to work. nothing is filtered when I type in the search boxes below each column.
My guess is that I will need to do some server side filtering based on the values entered into the fields at the bottom of each table?
If so, any suggestions/examples that might help?
Thanks
Jim

Replies

  • RRStoyanovRRStoyanov Posts: 12Questions: 0Answers: 0
    can you show your table code please?
  • jimvjimv Posts: 27Questions: 0Answers: 0
    edited October 2009
    RRStoyanov,
    Table code below, hope that is what you were looking for.

    I'm wondering if I need to look for search_last, search_zip, etc in the headers [code]($_GET[search_last])[/code], and then modify my select query where clause to filter on each of these??

    PHP server side code in dg_server_processing.php is mostly like server_processing.php example, only changed column names and DB info.

    Suggestions appreciated :-)
    Thanks
    Jim


    [code]

    @import "/css/demo_page.css";
    @import "/css/demo_table.css";






    var oTable;
    var asInitVals = new Array();

    $(document).ready(function() {
    oTable = $('#example').dataTable( {
    "oLanguage": {
    "sSearch": "Search all columns:"
    }
    } );

    $("tfoot input").keyup( function () {
    /* Filter on the column (the index) of this element */
    oTable.fnFilter( this.value, $("tfoot input").index(this) );
    } );



    /*
    * Support functions to provide a little bit of 'user friendlyness' to the textboxes in
    * the footer
    */
    $("tfoot input").each( function (i) {
    asInitVals[i] = this.value;
    } );

    $("tfoot input").focus( function () {
    if ( this.className == "search_init" )
    {
    this.className = "";
    this.value = "";
    }
    } );

    $("tfoot input").blur( function (i) {
    if ( this.value == "" )
    {
    this.className = "search_init";
    this.value = asInitVals[$("tfoot input").index(this)];
    }
    } );
    } );


    $(document).ready(function() {
    $('#deans_list').dataTable( {
    "oLanguage": {
    "sSearch": "Search all columns:"
    },
    "bProcessing": true,
    "bServerSide": true,
    "aaSorting": [[5,'asc'], [4,'asc']],
    "sPaginationType": "full_numbers",
    "bAutoWidth": false,
    "bSortClasses": false,
    "aoColumns": [ { "sType": "numeric" },null,{ "bSortable": false },null,null,{ "sWidth": "315PX" }],
    "sAjaxSource": '/dg_server_processing.php'
    } );
    } );





    ZIP
    LAST
    FIRST
    CITY
    STATE
    COLLEGE















    [/code]
  • RRStoyanovRRStoyanov Posts: 12Questions: 0Answers: 0
    Yup, I think your problem laying in your dg_server_processing.php ;) You need to be careful there anyway. Because if you use the filter for searching in all fields and in same time you want to user column filters, you definitely need to make your dg_server_processing.php to be able to handle both.
This discussion has been closed.