码迷,mamicode.com
首页 > 其他好文 > 详细

dataTable添加序号列

时间:2018-04-27 02:35:02      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:操作   cti   false   tab   table   获取   func   end   visible   

使用render( data, type, row, meta )的参数meta

直接新加一个列

columns: [
            {data: "id", title: "id", visible: false, searchable: false},
            {data: null, tile: "序号", visible: true, searchable: false},
            {data: "name", title: "名称", visible: true, searchable: false},
            {data: "createTime", title: "创建时间", visible: true, searchable: false},
            {data: null, title: "操作", visible: true, searchable: false} //序号为-1
        ],

然后columnDefs中使用meta.row

columnDefs: [
            {
                targets: 1,
                render: function (data, type, row, meta) {
                    return meta.row+1
                }
            }
        ],

然后就可以里

同样,meta.col是获取列号

dataTable添加序号列

标签:操作   cti   false   tab   table   获取   func   end   visible   

原文地址:https://www.cnblogs.com/srgk/p/8955315.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!