排序不工作的datatable插件 [英] sorting not working datatable plugin

查看:218
本文介绍了排序不工作的datatable插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


DataTables Cannot read property 'length' of undefined

I have same problem like the above link. I have a link to json data.

My JQUERY:

$('#card-table').DataTable({ "ajax": "http://project-maria-1350.appspot.com/getPeople?key=CX1231466035200" });

My HTML code:

`<div id="passenger" class="tab-pane fade in active">
  <table id="card-table" class="display" cellspacing="0" width="100%">
  <thead>
        <tr>
            <th>Last Name</th>
            <th>First Name</th>
            <th>Gender</th>
            <th>Nationality</th>
            <th>Age</th>
            <th>Class</th>
            <th>Boarding No.</th>
            <th>Seat No.</th>
            <th>Group Code</th>
        </tr>
    </thead>
  </table>
</div>`

I am getting Uncaught TypeError: Cannot read property 'length' of undefined.the data is displayed. But sorting is not working. Please help me.Thanks.

解决方案

Data tables expects the JSON object to have the format {"data": [{..,..},{...,...}]}.

Check this example https://datatables.net/examples/data_sources/ajax.html (click the tab "AJAX" and see the format).

You can change it.

这篇关于排序不工作的datatable插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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