使用ServerSide或bServerSide DataTable时出现奇怪的行为

时间:2014-08-13 14:28:39

标签: jquery ajax datatable

我正在处理以下代码:

    $(document).ready(function() {
        var refreshMaintTable = $('#maint-table').dataTable( {
            "sAjaxSource": 'pcheck/ajax/maint_json.txt',
            "ServerSide": true,
            "bJQueryUI": true,
            "bPaginate": false,
            "bLengthChange": false,
            "bFilter": false,
            "aoColumns": [
                { "mData": "maint_owner" },
                { "mData": "maint_desc" },
            ],
        } );
        setInterval (function() {
            refreshMaintTable.fnDraw();
        }, 500);
    } );
</script>

JSON数据:

{
  "draw": 1,
  "recordsTotal": 20,
  "recordsFiltered": 20,
  "data": [
    {
      "maint_owner": "cparrot",
      "maint_desc": "Trip to Dubai"
    },
    {
      "maint_owner": "mbean",
      "maint_desc": "Upgrade to iPhone"
    }
  ]
}

情景1:

与上述相似,

the result count shows **Showing 1 to 2 of 2 entries** which is correct
the refreshMaintTable does not refresh the data table

情景2:

当我从 ServerSide:true 更改为 bServerSide:true

the refreshMaintTable starts refreshing the data table
the result count then shows **Showing 1 to 2 of 20 entries** which is not correct since I only have 2 entries

我在使用服务器端处理之间是否有任何遗漏?

由于

1 个答案:

答案 0 :(得分:0)

我认为这是插件本身。文档中存在许多差异。它非常分散。数据表非常反复试验。