在jquery数据表中呈现大型服务器端数据集

在jquery数据表中呈现大型服务器端数据集

本文介绍了在jquery数据表中呈现大型服务器端数据集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用DataTables 1.9.4和几个插件(ColVis,ColReorderWithResize和ColumnFiltering).我用于服务器端通信的参数是:

I'm using DataTables 1.9.4 with few plugins (ColVis, ColReorderWithResize and ColumnFiltering). The parameters I'm using for server-side communication are:

  • "bServerSide"
  • "fnServerData"
  • "sAjaxSource"

现在,假设我必须显示3000行,约25列且没有分页("iDisplayLength":-1). json包含大约1MB的数据权重,服务器将其发送到数据表大约需要一秒钟的时间.

Now, let's say I have to display 3000 rows with around 25 columns without pagination ("iDisplayLength": -1). The json containing the data weights around 1MB and it takes around second for server to send it to datatables.

问题是渲染这3000行需要几秒钟(大约5-10,这是不可接受的).在IE上,可能要花更多的时间,从而导致脚本不响应"错误.

The problem is the rendering of those 3000 rows take few seconds (around 5-10, which is unacceptable). On IE, it can take quite more, resulting in "Script doesn't respond" errors.

我希望我可以以某种方式加快此过程的速度-即通过显示100条行并在背景中渲染其余行.有没有更好的办法?我知道有一个Scroller插件- Scroller ,但是我需要所有可用于搜索的数据,因此滚动是不是一个选择.

I wish I could speed this process up somehow - i.e. by showing lets say 100 rows and rendering the rest in background. Is there a better way? I know there's a Scroller plugin - Scroller, but I need all the data available for searching, so scrolling is not an option.

推荐答案

不幸的是,没有为大型数据集创建数据表.解决方法是使用服务器端处理.这意味着您需要根据页面索引实现要返回的数据.

unfortunately, datatables aren't made for large dataset. The way around it is to use server side processing. Which means you need to implement the data to be returned based on the page index.

以下是示例:
http://datatables.net/forums/discussion/2651/alternative -server-side-php-script http://www.datatables.net/examples/server_side/server_side.html

here are the examples:
http://datatables.net/forums/discussion/2651/alternative-server-side-php-scripthttp://www.datatables.net/examples/server_side/server_side.html

这篇关于在jquery数据表中呈现大型服务器端数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 00:09