Row drag only reordering first column

Row drag only reordering first column

Martin CMartin C Posts: 2Questions: 1Answers: 0

Using the RowReorder extension, and very happy with it but have an issue that only the first column seems to be getting reordered.
For example I have the following table:

I drag the bottom row to the top and you see that the input boxes haven't changed:

My table is initialised as follows:
// set datatable
$countriesDT = $('#countriestable').DataTable( {
bSort: false,
paging: false,
ordering: false,
searching: false,
info: false,
select: true,
rowReorder: true
});

Is there something obvious I'm doing wrong?

TIA,
Martin

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,276Questions: 26Answers: 4,765
    edited March 2019 Answer ✓

    It doesn't look like you have rowReorder setup correctly. You need to have odering enabled for it to work correctly. The RowReorder docs state:

    https://datatables.net/extensions/rowreorder/

    Basically it is swapping the data in your dataSrc column which is column 0 by default. You are seeing the data swap take place but since ordering is not enabled the items in column 0 move but the rest of the table doesn't. I don't think it has anything to do with the inputs.

    The docs also state:

    The data point in the row that is modified is defined by the rowReorder.dataSrc. Normally you will want this to be a sequential number! The data reorder can potentially confuse end users otherwise!

    The basic example illustrates using a sequential number as the data point:
    https://datatables.net/extensions/rowreorder/examples/initialisation/simple.html

    You can hide this column with columns.visible.

    Kevin

  • Martin CMartin C Posts: 2Questions: 1Answers: 0

    Amazing - thanks Kevin - that sorted it - clear case of RTFM!!!

This discussion has been closed.