使用带有特殊表头的jQuery数据表时出现问题

时间:2015-09-16 19:06:56

标签: javascript jquery html datatables

我正在尝试使用创建一个表格,其标题如下所示:

undefined

单独使用效果很好,但是当我使用进行尝试时,它根本不起作用。除了表头之外没有任何东西显示出来。

<table id="tableau" class="display" width="100%" align="center">
  <thead>
    <tr>
      <th colspan="2"></th>
      <th colspan="2"></th>
      <th rowspan="2"></th>
      <th colspan="2"></th>
      <th rowspan="2"></th>
    </tr>
    <tr>
      <th colspan="2"></th>
      <th></th>
      <th></th>
      <th></th>
      <th></th>
    </tr>
  </thead>
  <tbody>
  </tbody>
</table>

1 个答案:

答案 0 :(得分:0)

我发现他们在带有内容的金额列标题中有一些错误。检查此解决方案:

#newsleft
$(function() {
  var dataSet = [{
    "ta": "ta",
    "tb": "tb",
    "tc": "tc",
    "td": "td",
    "te": "te",
    "tf": "tf",
    "tg": "tg",
    "th": "th"
  }, {
    "ta": "ta",
    "tb": "tb",
    "tc": "tc",
    "td": "td",
    "te": "te",
    "tf": "tf",
    "tg": "tg",
    "th": "th"
  }, ];

  $("#tableau").DataTable({
    scrollY: "500px",
    scrollCollapse: true,
    autoWidth: true,
    paging: true,
    processing: true,
    info: true,
    ordering: true,
    searching: false,
    data: dataSet,
    columns: [{
      "data": "ta"
    }, {
      "data": "tb"
    }, {
      "data": "tc"
    }, {
      "data": "td"
    }, {
      "data": "te"
    }, {
      "data": "tf"
    }, {
      "data": "tg"
    }, {
      "data": "th"
    }]
  });
});

Demo

希望这会对你有所帮助。