have this function to the new version editor?

have this function to the new version editor?

scipiosoftscipiosoft Posts: 18Questions: 8Answers: 0

jQuery.fn.dataTable.Api.register('row.addByPos()', function(data, index) {
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 = this.row(i-1).data();
        this.row(i).data(tempRow);
        this.row(i-1).data(insertedRow);
    }     

    //refresh the current page
    this.page(currentPage).draw(false);
}); 

Replies

  • allanallan Posts: 61,824Questions: 1Answers: 10,131 Site admin

    Thanks for posting this!

    As I noted in your other thread the position of the data is given by the order of the data.

    Having said that, it looks like your code is overwriting the previous row's data (regardless of what it was). If that is what you require it will work well, but this isn't something that is likely to be included in the next DataTables or Editor release I'm afraid.

    Regards,
    Allan

This discussion has been closed.