jquery dataTable loads data in the background and paging

小云云
Release: 2018-01-10 10:26:29
Original
4619 people have browsed it

This article mainly introduces the jquery dataTable background loading data and paging example code, which has certain reference value. If you are interested, you can learn about it. I hope it can help everyone.

Use dataTable to load data in the background and paginate. There are many online versions, but many of them are unusable or not detailed. Here are the ones that have been verified.

Reference js file


Copy after login


 
Copy after login

Add a table tag, You can not use it, you can dynamically load


名称 apiKey secretKey 创建时间 Status 操作
Copy after login

Key JS code:


Copy after login

Backend code:


// 获取前端过来的参数,下面三个参数是 dataTable默认的,不要随便更改 Integer sEcho = Integer.valueOf(params.get("sEcho"));// 记录操作的次数 每次加1 Integer iDisplayStart = Integer.valueOf(params.get("iDisplayStart"));// 起始 Integer iDisplayLength = Integer.valueOf(params.get("iDisplayLength"));// 每页显示的size Map map = new HashMap(); try { // 查询数据,分页的话我这边使用的是 PageHelper,这边不介绍了 PagedResult list = pushEntityService.findByUserId( pushUser.getId(), iDisplayStart, iDisplayLength); // 为操作次数加1,必须这样做 int initEcho = sEcho + 1;
Copy after login


//返回参数也是固定的 map.put("sEcho", initEcho); map.put("iTotalRecords", list.getTotal());//数据总条数 map.put("iTotalDisplayRecords", list.getTotal());//显示的条数 map.put("aData", list.getDataList());//数据集合 } catch (Exception e) { e.printStackTrace(); } return map;
Copy after login

Related recommendations:

JQuery.dataTables table plug-in jumps to the specified page instance sharing

jquery DataTable front and backend dynamic paging implementation method sharing

About jQuery Datatable multiple query conditions custom submission event example sharing

The above is the detailed content of jquery dataTable loads data in the background and paging. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!