[英]Multiple DataTables in one page with differents parameters
我在同一頁面上有兩個dataTables,例如以下示例: https : //datatables.net/examples/basic_init/multiple_tables.html
直到沒有問題..
它具有許多共同的參數,例如按鈕或語言
$('table').DataTable({
language: {
search: "",
searchPlaceholder: "Search ...",
sLengthMenu:"_MENU_",
sInfo:"_TOTAL_ elmt",
infoFiltered: "",
sInfoEmpty: "0 elmt",
"oPaginate": {
"sPrevious": "<",
"sNext": ">"
}
}
});
但是,我希望為他們提供不同的pageLength
大小和不同的嘗試,我該怎么辦?
知道第一個表的ID是table-one
, 第二個 table-two
的ID是table-two
做這個:
// create an object with your settings for the first table
var dataTableOptions = {
language: {
search: "",
searchPlaceholder: "Search ...",
sLengthMenu:"_MENU_",
sInfo:"_TOTAL_ elmt",
infoFiltered: "",
sInfoEmpty: "0 elmt",
"oPaginate": {
"sPrevious": "<",
"sNext": ">"
}
}
};
// initialize that table
$('#table1').DataTable(dataTableOptions);
// modify whatever settings you need to in the object you created
dataTableOptions.language.sLengthMenu = "some new value";
// use the modified object to initialize the second table
$('#table2').DataTable(dataTableOptions);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.