Individual Column Filtering for Dynamically Generated Table

Individual Column Filtering for Dynamically Generated Table

DaveTDaveT Posts: 5Questions: 0Answers: 0
edited December 2010 in General
Hi! (First, I'm a first time forum poster so I'd like to say Thank You! for building DataTables.)

I can't figure out how to get Individual Column Filtering working for my Dynamically Generated Table. I'm trying to combine these two examples:
http://www.datatables.net/examples/api/multi_filter.html
http://www.datatables.net/examples/data_sources/server_side.html

My form initializes correctly, and the main search box (sSearch) works. But I can't get the other search inputs to filter. What am I doing wrong? Thanks in advance for any help.

(For the sake of getting things off the ground, I've keep a lot of the code (input names, etc) the same as the examples and I will change them once I get things to work.)

Footer of my table:













JavaScript:
$(document).ready(function() {
$('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "/crm/datatables/server_processing.php",
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
newclass = aData[4].replace(" ","");
$(nRow).addClass(newclass);
return nRow;
}

} );
var 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) );
} );

} );

Replies

  • DaveTDaveT Posts: 5Questions: 0Answers: 0
    Anyone have any ideas on this?
  • allanallan Posts: 63,512Questions: 1Answers: 10,472 Site admin
    You are using server-side processing - does the script you are using support individual column filtering? The one which comes with DataTables does (MySQL + PHP) - there are a number of others here, with feature listing: http://datatables.net/development/server-side/ .

    Oh - and you are initialising the table twice (does it not give you an error for that?!). Just more oLanguage into your first init object.

    Allan
  • DaveTDaveT Posts: 5Questions: 0Answers: 0
    edited December 2010
    Thanks Allan.
    I am using MySQL and PHP so that shouldn't be the problem. Is there anything in my code (other than initializing twice) that is wrong?

    As for initializing twice, it does not give me an error.
  • allanallan Posts: 63,512Questions: 1Answers: 10,472 Site admin
    I don't see anything obvious - can you link us to an example?

    Allan
  • DaveTDaveT Posts: 5Questions: 0Answers: 0
    http://inamegen.com/crm/datatables/

    It works in Firefox and Chrome for me. Not in IE or Safari.

    On a different note, the weird formatting you see below the DataTable is my in-process attempt to access all the data sent from the server (there are 18 hidden columns in the table) but I am having trouble accessing the data in the hidden columns.
  • allanallan Posts: 63,512Questions: 1Answers: 10,472 Site admin
    Safari is reporting a Javascript error in your fnRowCallback - the issue is that 'class' is a reserved word in Webkit's implementation of Javascript (presumably for forwards compatibility). You can add quote marks around it to take care of this (which would also be needed to make it valid JSON).

    For the hidden data - are you using fnGetData - you can't access the hidden columns using DOM methods since they are removed from the DOM.

    Allan
  • DaveTDaveT Posts: 5Questions: 0Answers: 0
    Thank you!!!!
    Not having quotes around "class" was the problem for IE as well!

    I was trying to use fnGetData but THEN was running into the problem of re-initializing.
This discussion has been closed.