Server Side multiple tables with column filtering, filtering not working on second table
Server Side multiple tables with column filtering, filtering not working on second table
I have 2 tables on same page using server side data. Each has a set of column filters. the first table's column filters works fine. For each change in filter, the server side script gets called. For the 2nd table, nothing happens. when data is place in filter, no call to server side script, and 'No matching records found" is displayed in 2nd table. Below is my javascript code followed by 2nd table definition. What am I doing wrong?
[code]
var asInitVals1 = new Array();
var asInitVals2 = new Array();
$(document).ready(function() {
var oTable1 = $('#merchantsearch').dataTable( {
"bLengthChange": false,
"bJQueryUI": true,
"bProcessing": false,
"bServerSide": true,
"sPaginationType": "full_numbers",
"sAjaxSource": "webservice1.php?method=Read",
"sDom": '<"top"ip><"H"lfr>t',
"fnDrawCallback": function( oSettings ) {
$('.top').css("display", "block");
$('.dataTables_filter').css("display", "none");
if (Math.ceil((this.fnSettings().fnRecordsDisplay()) / this.fnSettings()._iDisplayLength) > 1) {
$('#merchantsearch_paginate').css("display", "block");
} else {
$('#merchantsearch_paginate').css("display", "none");
}
var numcolumns = this.oApi._fnVisbleColumns(oSettings);
addRows(this, numcolumns, 10); // defined in FormFrame.js
},
"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
$('td:eq(4)', nRow).html('');
return nRow;
},
"oLanguage": {
"sSearch": "Search all columns:"
},
"aoColumns": [
null,
null,
null,
{"bSearchable": false},
{"bSearchable": false}
]
} );
var oTable2 = $('#usersearch').dataTable( {
"bLengthChange": false,
"bJQueryUI": true,
"bProcessing": false,
"bServerSide": true,
"sPaginationType": "full_numbers",
"sAjaxSource": "webservice2.php?method=Read",
"sDom": '<"top"ip><"H"lfr>t',
"fnDrawCallback": function( oSettings ) {
$('.top').css("display", "block");
$('.dataTables_filter').css("display", "none");
if (Math.ceil((this.fnSettings().fnRecordsDisplay()) / this.fnSettings()._iDisplayLength) > 1) {
$('#usersearch_paginate').css("display", "block");
} else {
$('#usersearch_paginate').css("display", "none");
}
var numcolumns = this.oApi._fnVisbleColumns(oSettings);
addRows(this, numcolumns, 10); // defined in FormFrame.js
},
"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
$('td:eq(5)', nRow).html('');
return nRow;
},
"oLanguage": {
"sSearch": "Search all columns:"
},
"aoColumns": [
null,
null,
null,
null,
{"bSearchable": false},
{"bSearchable": false}
]
} );
oTable2.fnSetColumnVis(0,false);
$('.top').css("display", "none");
$('.dataTables_filter').css("display", "none");
/* Merchant Search filter helper functions */
$("#merchantsearch tfoot input").keyup( function () {
/* Filter on the column (the index) of this element */
i = $("#merchantsearch tfoot input").index(this);
v = this.value;
oTable1.fnFilter( this.value, $("#merchantsearch tfoot input").index(this) );
} );
/*
* Support functions to provide a little bit of 'user friendlyness' to the textboxes in
* the footer
*/
$("#merchantsearch tfoot input").each( function (i) {
asInitVals1[i] = this.value;
} );
$("#merchantsearch tfoot input").focus( function () {
if ( this.className == "search_init1" )
{
this.className = "";
this.value = "";
}
} );
$("#merchantsearch tfoot input").blur( function (i) {
if ( this.value == "" )
{
this.className = "search_init1";
this.value = asInitVals1[$("#merchantsearch tfoot input").index(this)];
}
} );
/* User Search filter helper functions */
$("#usersearch tfoot input").keyup( function () {
/* Filter on the column (the index) of this element */
i = $("#usersearch tfoot input").index(this);
v = this.value;
oTable2.fnFilter( this.value, $("#usersearch tfoot input").index(this) );
} );
/*
* Support functions to provide a little bit of 'user friendlyness' to the textboxes in
* the footer
*/
$("#usersearch tfoot input").each( function (i) {
asInitVals2[i] = this.value;
} );
$("#usersearch tfoot input").focus( function () {
if ( this.className == "search_init2" )
{
this.className = "";
this.value = "";
}
} );
$("#usersearch tfoot input").blur( function (i) {
if ( this.value == "" )
{
this.className = "search_init2";
this.value = asInitVals2[$("#usersearch tfoot input").index(this)];
}
} );
} );
ID
Username
Name
Email
Telephone
Edit Action
[/code]
} );
} );
[code]
var asInitVals1 = new Array();
var asInitVals2 = new Array();
$(document).ready(function() {
var oTable1 = $('#merchantsearch').dataTable( {
"bLengthChange": false,
"bJQueryUI": true,
"bProcessing": false,
"bServerSide": true,
"sPaginationType": "full_numbers",
"sAjaxSource": "webservice1.php?method=Read",
"sDom": '<"top"ip><"H"lfr>t',
"fnDrawCallback": function( oSettings ) {
$('.top').css("display", "block");
$('.dataTables_filter').css("display", "none");
if (Math.ceil((this.fnSettings().fnRecordsDisplay()) / this.fnSettings()._iDisplayLength) > 1) {
$('#merchantsearch_paginate').css("display", "block");
} else {
$('#merchantsearch_paginate').css("display", "none");
}
var numcolumns = this.oApi._fnVisbleColumns(oSettings);
addRows(this, numcolumns, 10); // defined in FormFrame.js
},
"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
$('td:eq(4)', nRow).html('');
return nRow;
},
"oLanguage": {
"sSearch": "Search all columns:"
},
"aoColumns": [
null,
null,
null,
{"bSearchable": false},
{"bSearchable": false}
]
} );
var oTable2 = $('#usersearch').dataTable( {
"bLengthChange": false,
"bJQueryUI": true,
"bProcessing": false,
"bServerSide": true,
"sPaginationType": "full_numbers",
"sAjaxSource": "webservice2.php?method=Read",
"sDom": '<"top"ip><"H"lfr>t',
"fnDrawCallback": function( oSettings ) {
$('.top').css("display", "block");
$('.dataTables_filter').css("display", "none");
if (Math.ceil((this.fnSettings().fnRecordsDisplay()) / this.fnSettings()._iDisplayLength) > 1) {
$('#usersearch_paginate').css("display", "block");
} else {
$('#usersearch_paginate').css("display", "none");
}
var numcolumns = this.oApi._fnVisbleColumns(oSettings);
addRows(this, numcolumns, 10); // defined in FormFrame.js
},
"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
$('td:eq(5)', nRow).html('');
return nRow;
},
"oLanguage": {
"sSearch": "Search all columns:"
},
"aoColumns": [
null,
null,
null,
null,
{"bSearchable": false},
{"bSearchable": false}
]
} );
oTable2.fnSetColumnVis(0,false);
$('.top').css("display", "none");
$('.dataTables_filter').css("display", "none");
/* Merchant Search filter helper functions */
$("#merchantsearch tfoot input").keyup( function () {
/* Filter on the column (the index) of this element */
i = $("#merchantsearch tfoot input").index(this);
v = this.value;
oTable1.fnFilter( this.value, $("#merchantsearch tfoot input").index(this) );
} );
/*
* Support functions to provide a little bit of 'user friendlyness' to the textboxes in
* the footer
*/
$("#merchantsearch tfoot input").each( function (i) {
asInitVals1[i] = this.value;
} );
$("#merchantsearch tfoot input").focus( function () {
if ( this.className == "search_init1" )
{
this.className = "";
this.value = "";
}
} );
$("#merchantsearch tfoot input").blur( function (i) {
if ( this.value == "" )
{
this.className = "search_init1";
this.value = asInitVals1[$("#merchantsearch tfoot input").index(this)];
}
} );
/* User Search filter helper functions */
$("#usersearch tfoot input").keyup( function () {
/* Filter on the column (the index) of this element */
i = $("#usersearch tfoot input").index(this);
v = this.value;
oTable2.fnFilter( this.value, $("#usersearch tfoot input").index(this) );
} );
/*
* Support functions to provide a little bit of 'user friendlyness' to the textboxes in
* the footer
*/
$("#usersearch tfoot input").each( function (i) {
asInitVals2[i] = this.value;
} );
$("#usersearch tfoot input").focus( function () {
if ( this.className == "search_init2" )
{
this.className = "";
this.value = "";
}
} );
$("#usersearch tfoot input").blur( function (i) {
if ( this.value == "" )
{
this.className = "search_init2";
this.value = asInitVals2[$("#usersearch tfoot input").index(this)];
}
} );
} );
ID
Username
Name
Telephone
Edit Action
[/code]
} );
} );
This discussion has been closed.
Replies