当前位置:网站首页>JS - DataTables 关于每页显示数的控制
JS - DataTables 关于每页显示数的控制
2022-07-26 09:00:00 【愤世大魔头】
简单介绍
ataTable是一个十分有用的表格管理插件,在使用的过程中,我们只需要将数据给到datatable,datatable就能自动给我们管理表格,其功能包括分页、排序、搜索,等等。
这个前端插件还有个特点,就是显示字段由后端控制,数据请求,也是以接口的方式。
因此,刚接触的人,可能会不清楚,每页显示条目在哪里控制,我一开始走了弯路,现将"每页显示数的控制",总结如下。
问题关键
iDisplayLength:pageShowNums // 每页显示数
代码示例
JS代码操作位置:
let options = {
serverSide: true,
paging: true,
searching: false,
ordering: false,
iDisplayLength:100, // 【1】
ajax: {
url: "/user-manages" // 【2】
},
columns: [
@foreach ($columns as $column)
{data: "{
{ $column->name }}"} @if (!$loop->last) , @endif
@endforeach
], // 【3】
rowCallback: function(row, data) {
@can('manage diantai user')
let actions = '<a href="/user-manages/' + data.id + '/edit" class="btn btn-primary">编辑</a>'
actions += '<button class="btn btn-sm btn-delete" data-id="' + data.id + '"
data-toggle="modal" data-target="#modal_confirm">删除</button>';
$('td:eq({
{ count($columns) }})', row).html(actions)
$('#count_num').text(data.count);
@endcan
}
}
注解解释
【1】:就是控制列表显示条目数的设置,这些都是在js端控制
【2】:请求数据接口,即,你当前页的数据就是从这个接口请求而来
【3】:这部分,就是负责将后端的表格标头信息数据遍历展示
边栏推荐
- Typescript encryption tool passwordencoder
- Kotlin properties and fields
- [search topics] flood coverage of search questions after reading the inevitable meeting
- 数据库操作 题目二
- My meeting of OA project (query)
- Ueditot_ JSP SSRF vulnerability recurrence
- Pytoch learning - from tensor to LR
- P3743 Kotori's equipment
- mysql函数
- Innovus卡住,提示X Error:
猜你喜欢
Day06 homework - skill question 6
[eslint] Failed to load parser ‘@typescript-eslint/parser‘ declared in ‘package. json » eslint-confi
The lessons of 2000. Web3 = the third industrial revolution?
TCP solves the problem of short write
Day06 homework - skill question 7
对标注文件夹进行清洗
uni-app 简易商城制作
李沐d2l(六)---模型选择
海内外媒体宣发自媒体发稿要严格把握内容关
unity TopDown角色移动控制
随机推荐
力扣链表题
李沐d2l(五)---多层感知机
2022流动式起重机司机考试题模拟考试题库模拟考试平台操作
Learning notes of automatic control principle - Performance Analysis of continuous time system
How to quickly learn a programming language
(1) CTS tradefed test framework environment construction
谷粒学院的全部学习源码
ONTAP 9文件系统的限制
Zipkin安装和使用
day06 作业--增删改查
What are the differences in the performance of different usages such as count (*), count (primary key ID), count (field) and count (1)? That's more efficient
Database operation topic 2
QtCreator报错:You need to set an executable in the custom run configuration.
Day06 homework -- skill question 1
(2006,Mysql Server has gone away)问题处理
209. Subarray with the smallest length
Cat安装和使用
day06 作业--技能题6
【LeetCode数据库1050】合作过至少三次的演员和导演(简单题)
[search topics] flood coverage of search questions after reading the inevitable meeting