zoukankan      html  css  js  c++  java
  • layui 给数据表格加序号的方法

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

      (1)给数据加上 templet属性

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

      (2)在table的下面加上:

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

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

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

    加上type属性,

    1 ,cols: [[
    2  {field:'tourPlayerId', 80, title: 'ID1', sort: true,fixed: 'left',}
    3  ,{field:'zizeng', 80, title: '排名',fixed: 'left',type:'numbers'}

    设定列类型。可选值有:normal(常规列,无需设定)、checkbox(复选框列)、space(空列)、numbers(序号列)。

    注意:该参数为 layui 2.2.0 新增。而如果是之前的版本,复选框列采用 checkbox: true、空列采用 space: true

    效果如下:

  • 相关阅读:
    Strust2学习笔记
    EL与OGNL区别
    十进制与其他进制转换
    JSTL
    <jsp:include>和<%@include%>区别
    AngularJS 内置过滤器
    ubuntu下swift安装
    ubuntu下gerrit 安装部署
    java日期操作
    SpringMVC GET请求中文数据传递到Server端乱码
  • 原文地址:https://www.cnblogs.com/lgx5/p/14778114.html
Copyright © 2011-2022 走看看