jQuery DataTables:未捕获的TypeError:无法读取属性' mData'未定义 [英] jQuery DataTables: Uncaught TypeError: Cannot read property 'mData' of undefined

查看:99
本文介绍了jQuery DataTables:未捕获的TypeError:无法读取属性' mData'未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我会出错

未捕获的TypeError:无法读取未定义的属性'mData'

Uncaught TypeError: Cannot read property 'mData' of undefined

我尊重DataTables的要求(并且我还阅读了有关我的错误的另一个主题,并且尊重每个答案和解决方案).请帮助我.

I respect the DataTables requirements (and I also read another topics about my error and I respect every answer and solution). Please help me.

这是我的php代码:

<table class="table table-striped table-bordered table-hover" id="sample_1">
        <thead>
            <tr>
                <th class="table-checkbox">
                    <input type="checkbox" class="group-checkable" data-set="#sample_1 .checkboxes"/>
                </th>
                <th>
                     Utilizator
                </th>
                <th>
                     Nume complet
                </th>
                <th>
                     Clasa
                </th>
                <th>
                     Functia
                </th>
                <th>
                     E-Mail
                </th>
                <th>
                     Ultima logare
                </th>
            </tr>
        </thead>
        <tbody>
            <?
               foreach($data["users"] as $student)
               {
            ?>
            <tr class="odd gradeX">
                <td>
                    <input type="checkbox" class="checkboxes" value="1"/>
                </td>
                <td>
                     <? echo $student["username"]; ?>
                </td>
                <td>
                     <? echo " ".$student["last_name"]." ".$student["first_name"].""; ?>
                </td>
                <td>
                     <? echo getclass($student["class"]); ?>
                </td>
                <td>
                     <?
                     $functie = 0;
                     if($student["role"] == 1)
                     {
                         $functie = 1;
                         echo "Administrator site";
                     }
                     if($student["fctsc"])
                     {
                         $functie = 1;
                         echo "Director";
                     }
                     if($student["diriginte"])
                     {
                         $functie = 1;
                         echo "Diriginte";
                     }
                     if($student["profesor"])
                     {
                         $functie = 1;
                         echo "Profesor";
                     }
                     if($functie == 0)
                         echo "Elev";
                     ?>
                </td>
                <td>
                    <a href="mailto:<? echo $student["email"]; ?>">
                        <? echo $student["email"]; ?>
                    </a>
                </td>
                <td class="center">
                     <? echo $student["lastlogin"]; ?>
                </td>
            </tr>
            <?
               }
            ?>
        </tbody>
    </table>

推荐答案

通常,出现此错误的原因有两个:

Usually this error occurs for two reasons:

  • 缺少表头.
  • 表主体中的td元素数与表头中的th元素数不同.
  • Missing table header.
  • Number of td elements in the table body differs from number of th elements in the table header.

但是您的HTML代码似乎具有正确的列数,请参见此示例.

However your HTML code seems to have correct number of columns, see this example.

请参见 jQuery数据表:常见的JavaScript控制台错误-TypeError:无法读取未定义的属性'mData',以获取更多信息.

See jQuery DataTables: Common JavaScript console errors - TypeError: Cannot read property ‘mData’ of undefined for more information.

这篇关于jQuery DataTables:未捕获的TypeError:无法读取属性&amp;#39; mData&amp;#39;未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆