layui 给数据表格加序号或行号

摘自:https://blog.csdn.net/qq_40319394/article/details/80657832

第一种需求,只给当前页加序号

  1. 给你的数据加上 templet属性
,cols: [[
    {field:'tourPlayerId', width:80, title: 'ID1', sort: true,fixed: 'left',}
    ,{field:'zizeng', width:80, title: '排名',fixed: 'left',templet:'#zizeng'}
  1. 在table的下面加上:
<script type="text/html" id="zizeng">
    {{d.LAY_TABLE_INDEX+1}}
</script>

这样的话 下一页里面的排序不会连着上一页的,只会重新从1开始排序

第二种方法,包括分页的数据也加上序号

{ type: 'numbers', title: '序号', width: 180  }
, { field: 'StockCode', title: '仓库编号', width: 180, sort: true }
, { field: 'StockName', title: '仓库名称', width: 180, sort: true }

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/wohingradio88/article/details/83032939
今日推荐