如果我们不知道数据库中的条目总数,如何使用 deferLoading?

How to use deferLoading if we don't know the total amount of entries in the database?

我目前正在做一个项目,我在其中显示 Azure 上可用的每个虚拟机。由于有很多数据,我想使用 DataTable 中的 deferLoading。问题是,无论是我使用带有整数值的 deferLoading 还是数组值,在这两种情况下,我都不知道数据库中的条目总数是多少(数据库有时会更新,并且条目总数受变化)。

所以我想知道我该如何处理这个问题?

在等待使用 deferLoading 寻找解决方案的同时,我也在尝试更改 de drawCallback 选项,以更改单击“下一步”或“上一步”按钮时调用的函数。所以我只会在 datable 中加载 25 个新条目,这将替换 datatable.

中已经存在的数据

解决我的问题的另一种方法是使用静态 table,但我不会拥有 DataTable 可以提供的所有可能性。

这是当前的 JavaScript 代码:

$('#table').DataTable({
    pageLength: 25,
    /*
            
    processing: true,
    serverSide: true,
    deferLoading: [25, x],
            
    */
    drawCallback: function() {
        // .off() disables the regular action of #table_<name> button
        // so the program will only execute the function we want.
        $("#table_next").off().click(function(event) {
            showNextVMs();
        });
        $("#table_previous").off().click(function(event) {
            showPreviousVMs();
        });
    }
});

不要犹豫,分享任何建议,我以前从未使用过 DataTables,我可能会错过一些好的做法。

按照@cheesyMan 的建议,我在 DataTables 论坛上发布了我的答案。 Here 是答案的 link。