当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
Cat安装和使用
unity简易消息机制
PHP page value transfer
at、crontab
Dynamic SQL and exceptions of pl/sql
Learning notes of automatic control principle --- linear discrete system
高数 | 武爷『经典系列』每日一题思路及易错点总结
Kotlin properties and fields
Day06 homework -- skill question 1
公告 | FISCO BCOS v3.0-rc4发布,新增Max版,可支撑海量交易上链
Pytoch realizes logistic regression
JVM触发minor gc的条件
Uploading pictures on Alibaba cloud OSS
第6天总结&数据库作业
力扣链表题
The lessons of 2000. Web3 = the third industrial revolution?
数据库操作 题目二
mysql函数
idea快捷键 alt实现整列操作
Web概述和B/S架构






![[leetcode database 1050] actors and directors who have cooperated at least three times (simple question)](/img/ab/bad6b86039384af7b829bef5316923.png)

