How do you change the Sort (rowReorder) colum from the first column to the last?

How do you change the Sort (rowReorder) colum from the first column to the last?

koniahinkoniahin Posts: 186Questions: 39Answers: 7

This seems simple enough. By default the Order/rowOrder field is attached to the first column, column0, I believe. I tried moving it to the last field and it fails. What happens is that the new last field named Sort or Order does nothing. The new first field (column0) still shows the drag/drop functionality if you click on an id but nothing actually changes.

Other than reordering the columns, if there another parameter which must be added to instruct drag/drop to link to the new position?

Demo at: https://www.dottedi.xyz/bin/notepad.php

The relevant parameters:

    info: true,
    dom: 'Bfrtip',
    select: true,
    order: [ 0, "asc" ], /* Not to be confused with rowOrder, this only changes the default initial sort column. */
    rowReorder: { dataSrc: 'notes.rowOrder', editor:  editor },

The columns:

    columns: [
      // { data: 'notes.rowOrder', className: 'reorder' },
      { data: 'notes.id'},
      { data: 'notes.title' },
      { data: 'notes.date' },
      { data: 'note_categories.name' },
      { data: 'notes.summary' },
      { data: 'notes.rowOrder', className: 'reorder' },
    ]

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,315Questions: 26Answers: 4,948

    Use the rowReorder.selector option to set the element used to drag.

    order: [ 0, "asc" ], /* Not to be confused with rowOrder, this only changes the default initial sort column. */

    You will need to order by the column that has the index used for the rowReorder.dataSrc otherwise the reordering the rows won''t work as expected.

    Kevin

  • kthorngrenkthorngren Posts: 21,315Questions: 26Answers: 4,948

    Also take a look at this example using the full row for ordering for an example of rowReorder.selector.

    Kevin

  • koniahinkoniahin Posts: 186Questions: 39Answers: 7

    I changed the order to column5 (Sort). This has no effect.

    order: [ 5, "asc" ],

    I really don't see how the referenced example is related to this situation. The goal in my example is to have the first five columns of any row selectable upon click, then the last column only for drag/drop.

    When I moved the rowOrder column to the last one, if I move the cursor over it you get the hand (drag) cursor but it does nothing.

  • kthorngrenkthorngren Posts: 21,315Questions: 26Answers: 4,948
    Answer ✓

    I really don't see how the referenced example is related to this situation.

    The example is meant to show how to use the rowReorder.selector.

    The goal in my example is to have the first five columns of any row selectable upon click, then the last column only for drag/drop.

    Use the appropriate selector for what you want, such as td:last-child.

    Kevin

Sign In or Register to comment.