简体   繁体   English

表内的jQuery datatable表导致mData未定义

[英]jQuery datatable table inside table causing mData undefined

In one of my projects I am using datatables. 在我的一个项目中,我正在使用数据表。 This is one column structure in my table which is causing an error: 这是我表中的一个列结构,这会导致错误:

<th>
    <table class="table table-bordered table-condesed">
        <thead>
            <tr>
                <th colspan="7" class="text-center">Day Run</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>M</td>
                <td>T</td>
                <td>W</td>
                <td>T</td>
                <td>F</td>
                <td>S</td>
                <td>S</td>
            </tr>
        </tbody>
    </table>
</th>

Also this is the respective column: 这也是相应的列:

<td>
    <table class="table table-bordered">
        <tbody>
            <tr>
                <td tabindex="0">N</td>
                <td>N</td>
                <td>N</td>
                <td>N</td>
                <td>N</td>
                <td>N</td>
                <td>Y</td>
            </tr>
        </tbody>
    </table>
</td>

I don't know why but this is throwing an error when initialized. 我不知道为什么,但这在初始化时抛出错误。 This is the error I am facing. 这是我面临的错误。

Uncaught TypeError: Cannot read property 'mData' of undefined

I don't see anything wrong here. 我在这里没有发现任何问题。 Any idea why its does not work? 知道为什么它不起作用吗?

Here is the live demo Demo 这是现场演示Demo

This is because you are initializing datatable by using class like: 这是因为,要初始化datatable通过使用class ,如:

$('.table').dataTable({searching: false, paging: false, responsive: true});

and the column definition are different for both the table, I think this is the issue. 而且两个表的列定义都不同,我认为这是问题所在。

Do one thing, provide different id to both the table and initiate datatable with those id's 做一两件事,提供不同的id以两个表,并开始datatableid's

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM