当前位置:网站首页>JS - DataTables control on the number of displays per page
JS - DataTables control on the number of displays per page
2022-07-26 09:06:00 【Angry devil】
Brief introduction
ataTable Is a very useful form management plug-in , In use , We just need to give the data to datatable,datatable Can automatically give us the management form , Its functions include paging 、 Sort 、 Search for , wait .
This front-end plug-in has another feature , The display field is controlled by the backend , Data request , Also in the way of interface .
therefore , New contacts , It may not be clear , Each page shows where the entries are controlled , I took a detour at the beginning , Will now " Control of the number of displays per page ", Summarized below .
The point is
iDisplayLength:pageShowNums // Number of displays per page
Code example
JS Code operation location :
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"> edit </a>'
actions += '<button class="btn btn-sm btn-delete" data-id="' + data.id + '"
data-toggle="modal" data-target="#modal_confirm"> Delete </button>';
$('td:eq({
{ count($columns) }})', row).html(actions)
$('#count_num').text(data.count);
@endcan
}
}Explanation of notes
【1】: This is to control the setting of the number of items displayed in the list , These are all in js End control
【2】: Request data interface , namely , The data of your current page is requested from this interface
【3】: This part , It is responsible for traversing and displaying the table header information data at the back end
边栏推荐
猜你喜欢
随机推荐
聪明的美食家 C语言
Set of pl/sql -2
力扣——二叉树剪枝
Day06 homework -- skill question 1
数据库操作 题目二
Grain College of all learning source code
[recommended collection] MySQL 30000 word essence summary - query and transaction (III)
Pytoch learning - from tensor to LR
Espressif plays with the compilation environment
Summary of common activation functions for deep learning
(1) CTS tradefed test framework environment construction
[use of final keyword]
Database operation topic 2
redis原理和使用-安装和分布式配置
Pat grade a a1013 battle over cities
PHP和MySQL获取week值不一致的处理
Media at home and abroad publicize that we should strictly grasp the content
PHP page value transfer
2022化工自动化控制仪表操作证考试题模拟考试平台操作
760. 字符串长度









