使用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是获取列号
原文地址:https://www.cnblogs.com/srgk/p/8955315.html
时间: 2024-11-05 22:56:11