【问题标题】:Is angular ngx-datatable server side?角度 ngx-datatable 是服务器端吗?
【发布时间】:2021-11-01 11:41:26
【问题描述】:

我正在使用 ngx-datatable。在我的组件中,我得到了 500.000 个数据。

例如:test.component.ts

public Rows = [
    {
      id: 1,
      mail: 'test@test.com',
      status: 1,
    },
    {
      id: 2,
      mail: 'test@test.com',
      status: 1,
    },
    {
      id: 3,
      mail: 'test@test.com',
      status: 1,
    } 
    .....
    .....
    .....
    {
     id: 500000,
     mail: 'test@test.com',
     status: 0, }

如果我使用 ngx 数据表和分页,我的数据可以逐页拆分,或者所有数据只出现 1 次。我想知道我的结构是否正确。

【问题讨论】:

    标签: angular datatable


    【解决方案1】:

    在 ngx-datatable 中实现分页有两种可能的方式

    服务器端分页

    引用#server-side pagination

    当您浏览任何页面时,这需要您的前端中的自定义逻辑通过 API 调用从服务器获取数据(例如页面 1 [和每页 10 数据],来自服务器的前 1-10 个数据,对于页面2、11-20数据)

    客户端分页

    引用#client-side pagination

    此功能不需要额外的 API 调用,这将一次从服务器获取所有数据并从客户端分页,这意味着您的数据将自动分页

    当您一次获得 5000.000 行时,我相信您正在使用 ngx-datatable 中的客户端分页。您可以在此处查看客户端分页示例 - Code Example

    【讨论】:

    猜你喜欢
    • 2018-02-12
    • 2020-08-02
    • 1970-01-01
    • 1970-01-01
    • 2019-03-22
    • 2016-11-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多