Home >Web Front-end >Layui Tutorial >Add serial numbers to the data table through layui

Add serial numbers to the data table through layui

王林
王林forward
2020-12-23 09:39:134876browse

Add serial numbers to the data table through layui

The specific method is as follows:

(Learning video sharing: Programming video)

1. The first requirement, only Add a serial number to the current page

(1) Add the templet attribute

,cols: [[    {field:'tourPlayerId', width:80, title: 'ID1', sort: true,fixed: 'left',}    ,{field:'zizeng', width:80, title: '排名',fixed: 'left',templet:'#zizeng'}

to your data (2) Add

<script type="text/html" id="zizeng">    
    {{d.LAY_TABLE_INDEX+1}}
</script>

below the table, so the next page The sorting inside will not be connected to the previous page, but will only start from 1 again

Add serial numbers to the data table through layui

2. The second method, including paging data, also adds a serial number

Add the type attribute,

Add serial numbers to the data table through layui

Set the column type. Optional values ​​are: normal (regular column, no setting required), checkbox (checkbox column), space (empty column), numbers (serial number column). Note: This parameter is new for layui 2.2.0. If it is the previous version, the checkbox column uses checkbox: true, and the empty column uses space: true

So you only need to use type:'numbers' here,

The effect is as follows:

Add serial numbers to the data table through layui Add serial numbers to the data table through layui

Related recommendations: layui tutorial

The above is the detailed content of Add serial numbers to the data table through layui. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete