Preserve sorting after updating cell

Preserve sorting after updating cell

virag_raiyanivirag_raiyani Posts: 2Questions: 1Answers: 0
edited March 2018 in Free community support

I have a table which has editable fields in row.
now when i sort data based upon perticular value and then update editable cell value, I update datatable object values using below code

table.row("rowid").data("newData").draw(false);

The problem is that it changes row position anonymously only if we have sorted data manualy(ie not default sorting).
I want a result like even if i sort data manualy and then i update column, sorting settings should not change and row
position should be preserved.
How can i get this result?

Answers

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    Don't call draw(). A draw action will do a resort of the data in the table.

    Allan

  • virag_raiyanivirag_raiyani Posts: 2Questions: 1Answers: 0

    Hi Allan,
    If i will not call draw() Api it will not update datatable object value.
    For example I have added download functionality over datatable now if i change X cell value and not calling draw(). Now when i will download table data, that X cell value will come with old value ie value before edit.
    And to get X cell value after edit i need to update datatable object value.

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    There is no option to draw the table via draw() and not have it resort the table for the newly entered data.

    If you need to maintain the position of the row, you need to consider that in a custom sorting plug-in that will keep the row in place.

    Allan

This discussion has been closed.