Use the parameter meta of render( data, type, row, meta )
Add a new column directly
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: "Operation", visible: true , searchable: false } // The serial number is -1 ],
Then use meta.row in columnDefs
columnDefs: [ { targets: 1, render: function (data, type, row, meta) { return meta.row+1 } } ],
Then you can
Similarly, meta.col is to get the column number