使用jQuery数据表插件的服务器端分页 [英] Server Side Pagination with jQuery Data Tables plugin

查看:75
本文介绍了使用jQuery数据表插件的服务器端分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用数据表实现服务器端分页?目前,在页面加载时,我正在初始化数据表&通过Java Spring控制器使用来自数据库的数据(JSON)填充表.我通过在查询字符串中传递搜索条件来进行Ajax调用.由于我们有成千上万的记录,因此我们计划进行服务器端分页以提高性能.

How can I achieve server side pagination using data table? Currently, on load of page I am initializing the data table & filling the table with Data (JSON) coming from database via Java Spring controller. I am making an Ajax call by passing search criteria in query string. Since we have hundreds of thousands of records, we have planned for server side pagination to improve performance.

为此,后端服务开发人员提供了一项服务,该服务可以为我提供每页记录,但可以接受诸如页面编号,无页面记录,排序顺序,排序列之类的输入.

For this the backend service developer has given me a service that gives me the per page records but takes inputs like PAGE NUMBER, NO OF PAGE RECORDS, SORT ORDER, SORT COLUMN.

我必须重写数据表实现,以将这些数据通过Ajax请求查询字符串传递给服务.我不知道是否有办法实现这一目标.

I have to override data table implementation to pass these to service via Ajax request query string. I don't know if there is a way to achieve this.

推荐答案

如何使用数据表实现服务器端分页?

How can I achieve server side pagination using data table?

有关更多信息,请查看文档

For more info check out the documentation

$(document).ready(function() {
    $('#example').dataTable( {
        "processing": true,
        "serverSide": true,
        "ajax": "../server_side/scripts/server_processing.php"
    } );
} );

我建议您再次查看 docs .

使用服务器端处理向服务器发送请求时, DataTables将发送以下数据以便让服务器 知道需要什么数据 我不会复制所有参数,但这里只复制其中几个:

When making a request to the server using server-side processing, DataTables will send the following data in order to let the server know what data is required I would not copy all the parameters but only few of them here:

start, length, order[i][column]

那是我想得到的.

记住:

一旦DataTables发出了具有上述参数的数据请求, 发送到服务器,它期望将JSON数据返回给它, 设置以下参数:

Once DataTables has made a request for data, with the above parameters sent to the server, it expects JSON data to be returned to it, with the following parameters set:

并且您想亲自看一下这些属性,以免使这篇文章过长.

and you want to take a look at the properties yourself, in order not to make this post too long.

这篇关于使用jQuery数据表插件的服务器端分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆