Frederic
Frederic

Reputation: 387

RowReorder extension does not save position of the row

I'm using jQuery DataTables 1.10 and try to understand why this new function - rowReorder - does not work as it should.

In fact, the plugin itself works perfectly: I can easy drag & drop the entire row. However, it does not save new position of the row so I always get the initial order (which is useless then).

Can you please let me know what's wrong here? I use a very basic code here:

table = $('#myTable').DataTable({
     data: jsondata,
    aoColumns: col_label_group,
    fnRowCallback: function (nRow, aData, iDisplayIndex) {
        nRow.setAttribute('id', iDisplayIndex);  
    },
     rowReorder: {
        selector: 'tr'
    }
})

See example on jsFiddle: https://jsfiddle.net/frederic123/wrhh3tbu/

Upvotes: 2

Views: 2211

Answers (1)

Gyrocode.com
Gyrocode.com

Reputation: 58880

When using objects as a data source use rowReorder.dataSrc option to specify which property holds the sequence number.

rowReorder: {
     selector: 'tr',
     dataSrc: 'r'
},

See updated jsFiddle for code and demonstration.

Upvotes: 3

Related Questions