标签的数量与配置中的列数不匹配。 datatables.js

时间:2018-02-15 08:12:50

标签: javascript datatables

我有一个错误&#34;无法读取属性&#39;样式&#39;未定义&#34;在创建表时。 我尝试过数据表中的实例,并且它很完美,但是在现场并没有。我读到了该错误,发现问题是<th>标记的数量与配置中的列数不匹配。但是如何解决它????这是我的代码。

data_table = [
  {
    browser:"Firefox",
    confirmed:'<i class="hi-icon hi-icon-small icon-not-confirmed" title="Not confirmed yet">0</i>',
    country:"UK",
    date:"<span>2018-02-13</span><br><span>11:39:24</span>",
    field1:"hjkh ityui",
    field2:"tryjtyu@dfg.df",
    field3:"fghryjrtt yryj rtukr ttyeu r",
    os:"Windows NT",
    rowid:0,
    subid:4904557,
  },
  {
    browser:"Firefox",
    confirmed:'<i class="hi-icon hi-icon-small icon-not-confirmed" title="Not confirmed yet">0</i>',
    country:"UK",
    date:"<span>2018-02-13</span><br><span>11:39:24</span>",
    field1:"hjkh ityui",
    field2:"tryjtyu@dfg.df",
    field3:"fghryjrtt yryj rtukr ttyeu r",
    os:"Windows NT",
    rowid:0,
    subid:4904558,
  }
];

 var data_columns = [
  {data: "date", title: "&nbsp;Entry Date", mData: "date", sTitle: "&nbsp;Entry Date"},
  {data: "field1", title: "Name", mData: "field1", sTitle: "Name"},
  {data: "field2", title: "Email", mData: "field2", sTitle: "Email"},
  {data: "field3", title: "Your Comments", mData: "field3", sTitle: "Your Comments"},
  {data: "browser", title: "User's Browser", mData: "browser", sTitle: "User's Browser"},
  {data: "os", title: "User's OS", mData: "os", sTitle: "User's OS"},
  {data: "country", title: "User's Country", mData: "country", sTitle: "User's Country"},
  {data: "confirmed", title: "Confirmed", className: "columnCenter", mData: "confirmed", sTitle: "Confirmed", sClass: "columnCenter"},
  {data: "subid", title: "Submission ID", mData: "subid", sTitle: "Submission ID"}
];
    table = $('#entries').DataTable({

    "lengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
        "data": data_table,
    "columnDefs": [{ targets: -1, oderable: false, searchable: true }],
    "order": [[0,'desc']],
    "columns": data_columns
    });

0 个答案:

没有答案