Customer Filter on Multiple tables
Customer Filter on Multiple tables
johnnyxiang
Posts: 2Questions: 0Answers: 0
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
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
This discussion has been closed.
Replies
It seems so that the filter doesn't know for what table it should work.
You have to do it like this:
[code]var oTable0 = ...
var oTable1 = ...
var oTable2 = ...
oTable1.fnFilter( 'string');[/code]
[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