【发布时间】:2016-03-09 11:49:33
【问题描述】:
我正在使用 MVC。我有大量数据,我只需要有分页限制的数据。例如,如果页面大小为 10,我只想获取数据库中的前 10 条记录。
这是我的html:
<table class="table table-striped table-bordered table-hover" id="data_table">
<thead>
<tr>
<th> Anket Id </th>
<th> Anket Adı </th>
<th> Katılımcı </th>
<th> Soru </th>
<th> Aktif Gün </th>
<th> Dil </th>
<th> Durum </th>
<th> Kayıt Tarihi </th>
</table>
这是我的 JS:
var table = $('#data_table').DataTable({
"processing": true,
"serverSide": true,
"ajaxSource": "/Survey/ActiveSurveysPaging",
"dataSrc": "",
"aoColumns": [
{ "mDataProp": "Anket Id" },
{ "mDataProp": "Anket Adı" },
{ "mDataProp": "Katılımcı" },
{ "mDataProp": "Soru" },
{ "mDataProp": "Aktif Gün" },
{ "mDataProp": "Dil" },
{ "mDataProp": "Durum" },
{ "mDataProp": "Kayıt Tarihi"}
],
..........
这就是我的服务器以 json 形式返回的内容:
{"sEcho": 3,"iTotalRecords" : 1013,"iTotalDisplayRecords" : 1013,"aaData" : [["56523938aa9c580dac1858e5","anket-0","1001","8","11","TR","Aktif","22.11.2015 23:52"],
["5652393aaa9c580dac185918","anket-1","1000","8","11","TR","Aktif","22.11.2015 23:52"]]}
当我运行程序时,它在加载数据表时出现“无法读取未定义的属性长度”错误。我在哪里做错了,感谢任何解决方案。
【问题讨论】:
-
您使用什么技术?什么是数据表功能?服务器端代码是什么样的?
-
DataTable 函数是众所周知的 bootstart-dataTable ,我的服务器端代码是这样的: [HttpGet] public JsonResult ActiveSurveysPaging(int iDisplayStart, int iDisplayLength){..... return jsonObject }
标签: javascript ajax data-paging