使用服务器端处理时如何动态添加行?
我正在使用打开服务器端处理的数据表。
在某些情况下,数据库中的持久性是异步完成的,但当要添加某些内容并需要在客户端上显示时,我确实会在服务器上收到事件。在这种情况下,我想在客户端上添加一行并增加计数。
我实现的方法是按照以下步骤操作:
- 将 bserverside 设置为 false
- 调用
fnAddData()
- 将 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:
- set bserverside to false
- call
fnAddData()
- 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有一个第三方插件可用于将新记录添加到 JQuery DataTable http:// /jquery-datatables-editable.googlecode.com/svn/trunk/index.html。
您可以在 http://jquery-datatables-editable.googlecode 中查看示例.com/svn/trunk/addingrecords.html 和有关 http://code.google.com/p/jquery-datatables-editable/wiki /添加新记录
There is a third party plugin for adding new records into the JQuery DataTable http://jquery-datatables-editable.googlecode.com/svn/trunk/index.html.
You can see example in the http://jquery-datatables-editable.googlecode.com/svn/trunk/addingrecords.html and documentation on the http://code.google.com/p/jquery-datatables-editable/wiki/AddingNewRecords