Frederic Frederic - 1 year ago 87
jQuery Question

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:

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download