Customer Filter on Multiple tables

Customer Filter on Multiple tables

johnnyxiangjohnnyxiang Posts: 2Questions: 0Answers: 0
edited June 2010 in General
Hi Everyone.

i was following the example below to add customer filter.
http://www.datatables.net/examples/api/multi_filter.html

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


} );

it works fine for single table. but the problem is that when i moved on to multiple table, i cant figure out how to implement it. below is my code


jQuery(document).ready(function() {
var oTable = jQuery('.datatable').dataTable( {
'bPaginate':false,
"sDom": 'top rt<<"clear">'


} );

$("thead select").change( function () {
/* Filter on the column (the index) of this element */
//alert($(this).parent().parent().children().index($(this).parent()))
// get current th index
oTable.fnFilter( this.value, $(this).parent().parent().children().index($(this).parent()) );


} );
} );





Account
Currency
- All - USDEUR

Current Value
Status






John Lee Trust
USD
N/A
Not Released



John Lee Trust
EUR
N/A
Not Released




John Lee Trust
GBP

N/A
Not Released









Account

Portfolio
Currency
- All - USDEUR
Current Value
Status






John Lee Trust
Portfolio1
USD
N/A

Not Released




John Lee Trust
Portfolio1

EUR
N/A
Not Released









thanks

Replies

  • hasenumberonehasenumberone Posts: 14Questions: 1Answers: 0
    I've got the same problem. Anyone can help?

    It seems so that the filter doesn't know for what table it should work.
  • hasenumberonehasenumberone Posts: 14Questions: 1Answers: 0
    edited September 2010
    I solved the problem.

    You have to do it like this:

    [code]var oTable0 = ...
    var oTable1 = ...
    var oTable2 = ...

    oTable1.fnFilter( 'string');[/code]
  • allanallan Posts: 63,531Questions: 1Answers: 10,475 Site admin
    Can you not just do something like this:

    [code]

    $(document).ready(function() {
    var oTable1 = $('#example1').dataTable();

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


    var oTable2 = $('#example2').dataTable();

    $("#example2 tfoot input").keyup( function () {
    /* Filter on the column (the index) of this element */
    oTable2.fnFilter( this.value, $("tfoot input").index(this) );
    } );
    } );
    [/code]
    Allan
This discussion has been closed.