我在我的網站中使用jQuery數據表。我已將「多選項卡」功能和「Ajax Content loading」功能與數據表集成在一起。現在我想將搜索選項集成到我的數據表中。我的編碼是:jQuery數據表中的搜索選項
$(document).ready(function() {
$("#tabs").tabs({ // My datatable Div Id
"show": function(event, ui) {
var oTable = $('div.dataTables_scrollBody>table.display', ui.panel).dataTable();
if (oTable.length > 0) {
oTable.fnAdjustColumnSizing();
}
}
});
$('#example1').dataTable({ //example1->My first table Id
"bProcessing": true,
"sAjaxSource": "test_data.php", // "test_data.php" provides content for my first table
"bJQueryUI": true,
"sPaginationType": "full_numbers"
});
$('#example2').dataTable({ // example2->My second table Id
"bProcessing": true,
"sAjaxSource": "test_data2.php", // "test_data2.php" provides content for my second table
"bJQueryUI": true,
"sPaginationType": "full_numbers"
});
});
我在「示例數據表」中找到了解決搜索選項的方案。該編碼是:
var asInitVals = new Array();
$(document).ready(function() {
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));
});
/*
* 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)];
}
});
});
請指導我將上面的解決方案集成到我的代碼中,否則請給出您的建議以整合搜索選項。