layui 给数据表格加序号
1,第一种需求,只给当前页加序号
(1),给你的数据加上 templet属性
{field:‘zizeng’, width:80, title: ‘排名’,fixed: ‘left’,templet:’#zizeng’}
(2)在table的下面加上:
{field:'zizeng', width:80, title: '排名',fixed: 'left',templet:'#zizeng'}
<!--序号自增-->
<script type="text/html" id="zizeng">
{{d.LAY_TABLE_INDEX+1}}
</script>
这样的话 下一页里面的排序不会连着上一页的,只会重新从1开始排序
2,第二种方法,包括分页的数据也加上序号
{
title: '序号',
align: 'center',
type:'numbers'
}
加上type属性,设定列类型。可选值有:normal(常规列,无需设定)、checkbox(复选框列)、space(空列)、numbers(序号列)。