How to fix the table header in layui: first find the table.js file in layui; then add the fiexdRowHeight attribute to the variable table; finally add the code "if(Object.prototype.toString.call(.. .))" will do.
Recommended: "layUI Tutorial"
Achievement effect: The header and bottom pagination are fixed, and the mouse scrolling will only Scroll the data in the body. The effect is as follows:
1. Find the table.js file in layui and add attributes to the variable table, as shown in the red box:
fiexdRowHeight: Whether to enable fixed row height, the default is false
fiexdRowHeight_rows: The number of rows displayed in the table, the default is 10
Both of the above two parameters can be passed in by themselves
2. Find the pullData function:
In this function, add the last one in the success function of the ajax asynchronous request success callback The following code:
//固定行高、表头处理 if(Object.prototype.toString.call(options.fiexdRowHeight).slice(8, -1) === 'Boolean' && options.fiexdRowHeight) { var p_ = $("[lay-id='" + options.id + "']") var tr_len = p_.find(ELEM_MAIN).find("tr").length if(tr_len > 10){ if(Object.prototype.toString.call(options.fiexdRowHeight_rows).slice(8, -1) !== 'Number') { options.fiexdRowHeight_rows = 10 } var height_main = (options.fiexdRowHeight_rows * 39) + 'px' var height_fixed = (options.fiexdRowHeight_rows * 39) + 'px' //如果出现横向滚动条时 if(p_[0].parentNode.clientWidth <p>3. Application: As shown in the figure: </p><p><img src="/static/imghwm/default1.png" data-src="https://img.php.cn/upload/article/000/000/020/9c81d91dfd517f91ecd499759e6764c7-4.png?x-oss-process=image/resize,p_40" class="lazy" style="max-width:90%" style="max-width:90%" alt="How to fix the header of the table in layui" ></p>
The above is the detailed content of How to fix the header of the table in layui. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver CS6
Visual web development tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Zend Studio 13.0.1
Powerful PHP integrated development environment

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool