未捕获的类型错误:无法读取未定义的属性“aDataSort" [英] Uncaught TypeError: Cannot read property 'aDataSort' of undefined

查看:34
本文介绍了未捕获的类型错误:无法读取未定义的属性“aDataSort"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理分页,我正在使用 DataTables 插件,在某些表上它可以工作,但在某些表上它给出错误:

i am working on pagination and i am using DataTables plugin , on some tables it's work but on some tables it gives error:

未捕获的类型错误:无法读取未定义的属性aDataSort"

Uncaught TypeError: Cannot read property 'aDataSort' of undefined

我的页面脚本如下:

$(document).ready(function() {
     $('.datatable').dataTable( {
        "scrollY":        "200px",
        "scrollCollapse": true,
        "info":           true,
        "paging":         true
    } );
} );

//HTML代码

<table class="table table-striped table-bordered datatable">
   <thead>
        <tr>
          <th><?php echo lang('date_label')?></th>
          <th><?php echo lang('paid_label')?></th>
          <th><?php echo lang('comments_label');?></th>
        </tr>
   </thead>
   <tbody>
      <?php foreach ($payments as $pay): ?>
      <tr>
        <td><?php echo dateformat($pay['time_stamp'], TRUE);?></td>
        <td><?php echo format_price($pay['amount']);?></td>
        <td><?php echo $pay['note'];?></td>
      </tr>
      <?php endforeach?>
   </tbody>
</table>

不知道问题是怎么来的,我知道这是很常见的错误,但我搜索并没有发现任何支持我的问题的错误.
有谁知道解决办法吗?

no idea how the problem comes ,i know this is very common error but i search and found nothing supporting my problem .
does anyone knows the solution ?

推荐答案

在您的代码中使用类似以下内容来禁用对 DataTables 的排序(改编自我使用最新 的项目数据表)

use something like the following in your code to disable sorting on DataTables (adapted from a project of mine which uses latest DataTables)

$(document).ready(function() {
     $('.datatable').dataTable( {
        'bSort': false,
        'aoColumns': [ 
              { sWidth: "45%", bSearchable: false, bSortable: false }, 
              { sWidth: "45%", bSearchable: false, bSortable: false }, 
              { sWidth: "10%", bSearchable: false, bSortable: false } 
        ],
        "scrollY":        "200px",
        "scrollCollapse": true,
        "info":           true,
        "paging":         true
    } );
} );

aoColumns 数组描述了每列的宽度及其 sortable 属性,根据您自己的表(数)列的需要进行调整.

the aoColumns array describes the width of each column and its sortable properties, adjust as needed for your own table (number of) columns.

这篇关于未捕获的类型错误:无法读取未定义的属性“aDataSort"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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