私のサイトではjQueryデータテーブルを使用しています。私はデータセットに "マルチタブ"機能と "Ajaxコンテンツロード"機能を統合しました。今、データテーブルに検索オプションを統合したいと思います。私のコーディングは: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)];
}
});
});
私のコードで上記のソリューションを統合するために私を導いてください。そうでない場合は、検索オプションを統合するためにあなたの提案をお願いします。