Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 数据表子行_Javascript_Jquery_Datatable - Fatal编程技术网

Javascript 数据表子行

Javascript 数据表子行,javascript,jquery,datatable,Javascript,Jquery,Datatable,我在尝试重新创造 我的名字是 前端Javascript $(document).ready(function() { $('#example').DataTable({ responsive: { details: { type: 'column', target: 'tr' } }, columnDefs: [{ className: 'control', orderable: fals

我在尝试重新创造

我的名字是

前端Javascript

$(document).ready(function() {
  $('#example').DataTable({
    responsive: {
      details: {
        type: 'column',
        target: 'tr'
      }
    },
    columnDefs: [{
      className: 'control',
      orderable: false,
      targets: 0
    }],
    order: [1, 'asc']
  });
});
HTML


测试
测试
测试
测试
测试
1.
2.
3.
4.
5.
由于未知原因,“详细信息”行不会出现(最左侧列上的+/-符号也不会出现)

我做错了什么?

您有两个问题:

  • 您没有使用正确的库
  • 您使用的是基于宽度自动隐藏数据的响应扩展插件。因此,您必须添加更多列,以便数据溢出
  • 请参阅更新的


    @RacilHilan我提供的示例(官方文档)也没有显式地设置详细信息行。它只使用了最后一个TDP,为什么不开始复制整个演示,确保它正常工作,然后开始修改它呢?您缺少一些CSS和JavaScript引用(响应的引用)。加上它们,你就能让它工作了。
    <table id="example" class="display nowrap" width="100%">
      <thead>
        <tr>
          <th></th>
          <th>test</th>
          <th>test</th>
          <th>test</th>
          <th>test</th>
          <th>test</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td></td>
          <td>1</td>
          <td>2</td>
          <td>3</td>
          <td>4</td>
          <td>5</td>
        </tr>
      </tbody>
    </table>
    
    Look at the used external resources to see the correct libraries to import.