簡體   English   中英

一頁中具有不同參數的多個數據表

[英]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大小和不同的嘗試,我該怎么辦?

知道第一個表IDtable-one第二個 table-twoIDtable-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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM