使用服务器端处理时如何动态添加行?

发布于 2024-12-04 18:39:44 字数 400 浏览 3 评论 0原文

我正在使用打开服务器端处理的数据表。

在某些情况下,数据库中的持久性是异步完成的,但当要添加某些内容并需要在客户端上显示时,我确实会在服务器上收到事件。在这种情况下,我想在客户端上添加一行并增加计数。

我实现的方法是按照以下步骤操作:

  1. 将 bserverside 设置为 false
  2. 调用 fnAddData()
  3. 将 bserverside 设置为 true

这种方式会在客户端上添加行,但由于客户端只有当前页面 - 记录总数变为(页面大小 + 1)而不是(之前的总计数 + 1)。我尝试更改 settings._iRecordsTotal 但没有帮助。

您能帮助我或为我提供任何其他方法吗?

I am using datatables with server-side processing turned on.

There are instances where persistence in database is done asynchronously, but I do get the event on server when something will be added and need to show that on the client. In that case, I want to add a row on client and increment the count.

The way I implemented is by following these steps:

  1. set bserverside to false
  2. call fnAddData()
  3. set bserverside to true

This way row gets added on the client but since client only had current page - the total number of records become (page size + 1) instead of (previous total count + 1). I tried changing settings._iRecordsTotal but it doesnt help.

Can you please help or provide me with any other approach?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文