dataTable添加序号列

使用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是获取列号

posted @ 2018-04-26 22:12  SrGK  阅读(535)  评论(0编辑  收藏  举报