jquery.dataTable()如何在行中间插入一行,不要用jquery写法,要用dataTable自带的方法。这样才能行序号加1
datatable 没有提供api插入到指定位置,只有一个add添加到最后,都是扩展的出来的,自己看这个2个
https://stackoverflow.com/questions/30712227/datatables-row-add-to-specific-index
https://datatables.net/forums/discussion/29147/put-new-rows-at-the-specific-position-of-the-jquery-datatable
楼上正解,api里面只有加到最后或者最前
jQuery.fn.dataTable.Api.register('row.addByPos()', function(data, index,table) {
debugger;
var currentPage = this.page();
//insert the row
this.row.add(data);
//move added row to desired index
var rowCount = this.data().length-1,
insertedRow = this.row(rowCount).data(),
tempRow;
for (var i=rowCount;i>=index;i--) {
tempRow = table.row(i-1).data();
this.row(i).data(tempRow);
this.row(i-1).data(insertedRow);
}
//refresh the current page
this.page(currentPage).draw(false);
});
这个怎么给你积分那,怎么结束啊