How to save the new rows order while paging

How to save the new rows order while paging

taiebtaieb Posts: 2Questions: 1Answers: 0

Hello there !

I am using jquery sortable with datatable (to sort my rows with drag&drop) and it works fine.
The proble is after sorting, if I move to another page with datatable pagination, I lose the rows order and I have the initial order !

How to save the new order state of the current page ? (like stateSave do before page refresh)

Many thanks !

Answers

  • taiebtaieb Posts: 2Questions: 1Answers: 0

    I found a solution !
    Since the jquery Sortable don't affect the object instanciated with Datatable,
    I update every row in the Datatable table with the new content of the html table using table.row(index).data(newRowContent).draw(false).
    draw(false) to save the page state ;)

  • AshbjornAshbjorn Posts: 55Questions: 2Answers: 16

    Hi taieb,

    The behavior you are describing could also be evident when your columns are not using the "data" property.

    i.e.

    "columns": [
        { "data": "id" },
        { "data": "firstname" },
    ],
    

    instead of

    "columns": [
        { "name": "id" },
        { "name": "firstname" },
    ],
    

    At least that's what fixed my behavior, which seems similar at least to what you are describing.

    Hope this helps,

This discussion has been closed.