【问题标题】:DataTables: When hiding table header ... the table is not collapsing when in mobile viewDataTables:隐藏表格标题时...在移动视图中表格不会折叠
【发布时间】:2018-04-17 12:39:07
【问题描述】:

我想隐藏表格标题...但是当这样做并且表格处于响应模式时...列没有折叠。请看小提琴:http://jsfiddle.net/wceu020b/

<table id="example" class="display" cellspacing="0" width="100%">
    <thead>
        <tr>
            <th>Name</th>
            <th>Position</th>
            <th>Office</th>
            <th>Age</th>
            <th>Start date</th>
            <th>Salary</th>
        </tr>
    </thead>

    <tbody>
        <tr>
            <td>Tiger Nixon</td>
            <td>System Architect</td>
            <td>Edinburgh</td>
            <td>61</td>
            <td>2011/04/25</td>
            <td>$320,800</td>
        </tr>
        <tr>
            <td>Garrett Winters</td>
            <td>Accountant</td>
            <td>Tokyo</td>
            <td>63</td>
            <td>2011/07/25</td>
            <td>$170,750</td>
        </tr>
        <tr>
            <td>Ashton Cox</td>
            <td>Junior Technical Author</td>
            <td>San Francisco</td>
            <td>66</td>
            <td>2009/01/12</td>
            <td>$86,000</td>
        </tr>
        <tr>
            <td>Cedric Kelly</td>
            <td>Senior Javascript Developer</td>
            <td>Edinburgh</td>
            <td>22</td>
            <td>2012/03/29</td>
            <td>$433,060</td>
        </tr>
    </tbody>
</table>

css:

table th:nth-child(3), td:nth-child(3) {
  display: none;
}

table thead {
  display:none;
}

js:

$(document).ready(function() {
    $('#example').DataTable( {
        responsive: true
    } );
} );

如何隐藏标题并仍然使列折叠?

【问题讨论】:

    标签: jquery datatables


    【解决方案1】:

    这与此线程非常相似:How to suppress table headers completely in jQuery DataTables?,尽管其他线程没有提及Responsive

    如果您从其他线程中获取@s.krueger 的答案,您将得到它的工作 - 在这里查看这个小提琴:http://jsfiddle.net/y315obr4/4/

    【讨论】:

    • 优秀。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-24
    • 2010-10-10
    • 2018-01-04
    相关资源
    最近更新 更多