【问题标题】:How to make server-side paging in datatable?如何在数据表中进行服务器端分页?
【发布时间】: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


【解决方案1】:

尝试类似JqGrid 如果你想用分页实现自己的表格,像 Jqgrid 一样做

【讨论】:

  • 您好,我在这个链接中看不到分页部分,您能帮我找到吗?
  • server side pagination 在这里找到
猜你喜欢
  • 2016-12-23
  • 1970-01-01
  • 2016-01-05
  • 2019-04-16
  • 1970-01-01
  • 2012-03-06
  • 2020-04-28
  • 1970-01-01
  • 2016-10-21
相关资源
最近更新 更多