Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.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
jQuery Datatables大型数据集未捕获类型错误:无法读取属性';mData';未定义的_Jquery_Datatables_Metronic - Fatal编程技术网

jQuery Datatables大型数据集未捕获类型错误:无法读取属性';mData';未定义的

jQuery Datatables大型数据集未捕获类型错误:无法读取属性';mData';未定义的,jquery,datatables,metronic,Jquery,Datatables,Metronic,因此,在使用php从数据库中迭代的一大组行上出现控制台错误。我用metronic主题来初始化这个。正如你所看到的,我有我的头像和身体 我怀疑问题可能与输出的大小有关,可能需要使用另一种方法,欢迎任何指导 <table id="sample_1" class="table table-striped table-bordered table-hover"> <thead> <tr> <th class="

因此,在使用php从数据库中迭代的一大组行上出现控制台错误。我用metronic主题来初始化这个。正如你所看到的,我有我的头像和身体

我怀疑问题可能与输出的大小有关,可能需要使用另一种方法,欢迎任何指导

<table id="sample_1" class="table table-striped table-bordered table-hover">
    <thead>
          <tr>
            <th class="table-checkbox">
              <input type="checkbox" class="group-checkable" data-set="#sample_1 .checkboxes"/>
            </th>
            <th>Name</th>
            <th>Source</th>
            <th>Email</th>
            <th>Customer</th>
            <th>Created</th>
            <th>Login</th>
            <th>Active</th>
            <th>Role</th>
            <th>Incentive</th>
            <th>View</th>
            <th>Switch</th>
            <th>Email</th>
          </tr>        
        </thead>
      <tbody>

      <?php
        $users=user::get_all($filter);
        if($users){
          foreach($users as $row){
            $customer=user::get_cutomer_name_by_source_id($row['source_id']);
            ?>
            <tr class='odd gradeX'>
              <td><input type='checkbox' class='checkboxes' value='1'/></td>
              <td><?php echo $row['first_name']." ".$row['last_name']; ?></td>
              <td><?php echo $row['source_id']; ?></td>
              <td><?php echo $row['email']; ?></td>
              <td><?php echo $customer; ?></td>
              <td><?php echo date("m/d/Y", strtotime($row["created"])); ?></td>
              <td><?php if($row['login']!=NULL){echo date("m/d/Y",$row['login']);} ?></td>
              <td><?php if($row['active']==1){echo "Yes";}else{echo "No";} ?></td>
              <td><?php echo user::get_role_name($row['rid']); ?></td>
              <td><?php 
                if($row['cash_incentive']==1){echo "Cash";}else{echo "Regular";} ?>
                </td>
              <td><a href='user-edit?uid="<?php echo $row['uid']; ?>"'>View </a></td>
              <td><a href='switch?email="<?php echo $row['email']; ?>"'> Switch</a></td>
              <td><input type='checkbox' name='email-list[]' value='<?php echo $row['email']; ?>'></td>
            </tr>   
          <?php }
        }
      ?>

</tbody>

名称
来源
电子邮件
顾客
创建
登录
忙碌的
角色
激励
看法
转换
电子邮件

下面是datatable的metronic init:

table.dataTable({

        // Internationalisation. For more info refer to http://datatables.net/manual/i18n
        "language": {
            "aria": {
                "sortAscending": ": activate to sort column ascending",
                "sortDescending": ": activate to sort column descending"
            },
            "emptyTable": "No data available in table",
            "info": "Showing1 _START_ to _END_ of _TOTAL_ entries1",
            "infoEmpty": "No entries found",
            "infoFiltered": "(filtered1 from _MAX_ total entries)",
            "lengthMenu": "Show _MENU_ entries",
            "search": "Search:",
            "zeroRecords": "No matching records found"
        },

        // Or you can use remote translation file
        //"language": {
        //   url: '//cdn.datatables.net/plug-ins/3cfcc339e89/i18n/Portuguese.json'
        //},

        // Uncomment below line("dom" parameter) to fix the dropdown overflow issue in the datatable cells. The default datatable layout
        // setup uses scrollable div(table-scrollable) with overflow:auto to enable vertical scroll(see: assets/global/plugins/datatables/plugins/bootstrap/dataTables.bootstrap.js). 
        // So when dropdowns used the scrollable div should be removed. 
        //"dom": "<'row'<'col-md-6 col-sm-12'l><'col-md-6 col-sm-12'f>r>t<'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>",

        "bStateSave": true, // save datatable state(pagination, sort, etc) in cookie.

        "columns": [{
            "orderable": false
        }, {
            "orderable": true
        }, {
            "orderable": false
        }, {
            "orderable": false
        }, {
            "orderable": true
        }, {
            "orderable": true
        }, {
            "orderable": true
        }, {
            "orderable": true
        }, {
            "orderable": true
        }, {
            "orderable": true
        }, {
            "orderable": true
        }, {
            "orderable": false
        }],
        "lengthMenu": [
            [5, 15, 20, -1],
            [5, 15, 20, "All"] // change per page values here
        ],
        // set the initial value
        "pageLength": 5,            
        "pagingType": "bootstrap_full_number",
        "language": {
            "search": "My search: ",
            "lengthMenu": "  _MENU_ records",
            "paginate": {
                "previous":"Prev",
                "next": "Next",
                "last": "Last",
                "first": "First"
            }
        },
        "columnDefs": [{  // set default column settings
            'orderable': false,
            'targets': [0]
        }, {
            "searchable": false,
            "targets": [0]
        }],
        "order": [
            [1, "asc"]
        ] // set first column as a default sort by asc
    });
table.dataTable({
//国际化。有关更多信息,请参阅http://datatables.net/manual/i18n
“语言”:{
“咏叹调”:{
“排序设置”:“激活以对列升序排序”,
“sortDescending”:“激活以对列进行降序排序”
},
“emptyTable”:“表中没有可用数据”,
“信息”:“显示总分录1的开始到结束”,
“infoEmpty”:“未找到任何条目”,
“infoFiltered:”(filtered1来自“最大总条目数”),
“长度菜单”:“显示菜单项”,
“搜索”:“搜索:”,
“zeroRecords”:“未找到匹配的记录”
},
//或者您可以使用远程翻译文件
//“语言”:{
//url:“//cdn.datatables.net/plug-ins/3cfcc339e89/i18n/葡萄牙语.json”
//},
//取消第行(“dom”参数)下方的注释,以修复datatable单元格中的下拉溢出问题。默认datatable布局
//安装程序使用可滚动div(table scrollable)和overflow:auto来启用垂直滚动(请参阅:assets/global/plugins/datatables/plugins/bootstrap/datatables.bootstrap.js)。
//因此,当使用下拉列表时,应删除可滚动div。
//“dom”:“t”,
“bStateSave”:true,//在cookie中保存数据表状态(分页、排序等)。
“栏目”:[{
“可订购”:false
}, {
“可订购”:真
}, {
“可订购”:false
}, {
“可订购”:false
}, {
“可订购”:真
}, {
“可订购”:真
}, {
“可订购”:真
}, {
“可订购”:真
}, {
“可订购”:真
}, {
“可订购”:真
}, {
“可订购”:真
}, {
“可订购”:false
}],
“长度菜单”:[
[5, 15, 20, -1],
[5,15,20,“全部”]//此处更改每页的值
],
//设置初始值
“页面长度”:5,
“pagingType”:“引导程序\u完整\u编号”,
“语言”:{
“搜索”:“我的搜索:”,
“长度菜单”:“菜单记录”,
“分页”:{
“上一个”:“上一个”,
“下一步”:“下一步”,
“last”:“last”,
“第一”:“第一”
}
},
“columnDefs”:[{//设置默认列设置
“orderable”:false,
“目标”:[0]
}, {
“可搜索”:错误,
“目标”:[0]
}],
“命令”:[
[1,“asc”]
]//按asc将第一列设置为默认排序
});
原因 由选项指定的数组中的项数应与
元素数匹配。数组中有12个元素和13个
元素

从:

请注意,如果使用
columns
定义列,则必须在数组中为表中的每一列指定一个条目(如果不指定任何选项,则这些条目可以是
null

解决方案 将额外对象添加到
数组中,以匹配HTML中的列数

或者,为了可读性,您可以完全用
columnDefs
替换
columns

“columnDefs”:[{
“可订购”:错误,
“可搜索”:错误,
“目标”:[0]
}, {
“可订购”:错误,
“目标”:[2,3,11,12]
}
],
链接 有关此错误和其他常见控制台错误的更多信息,请参阅。

原因 由选项指定的数组中的项数应与
元素数匹配。数组中有12个元素和13个
元素

从:

请注意,如果使用
columns
定义列,则必须在数组中为表中的每一列指定一个条目(如果不指定任何选项,则这些条目可以是
null

解决方案 将额外对象添加到
数组中,以匹配HTML中的列数

或者,为了可读性,您可以完全用
columnDefs
替换
columns

“columnDefs”:[{
“可订购”:错误,
“可搜索”:错误,
“目标”:[0]
}, {
“可订购”:错误,
“目标”:[2,3,11,12]
}
],
链接
有关此错误和其他常见控制台错误的更多信息,请参阅。

是否可以同时添加JavaScript代码?是否可以同时添加JavaScript代码?太棒了!一直以来都是些小东西,我添加了一个复选框列,再也没有回去更新。干杯明亮的一直以来都是些小东西,我添加了一个复选框列,再也没有回去更新。干杯