rowReorder is failing whie "ordering" option is declared

rowReorder is failing whie "ordering" option is declared

vismarkvismark Posts: 79Questions: 5Answers: 0

I'm trying to insert the rowReorder extension in a table parsed dynamically. No matter if "ordering" option is set to true or false, if i drag a row, only the cell on which i clicked is being reordered. The rest of the row reverts back to its original position.

The only way i've found to make it work is to comment out the "ordering" option, which is not acceptable to mantain a dynamical parsing design.
I even trued declaring "order: []" but it makes the script fail as well (i need to comment out this line too).

Am I missing something? Is there any additional option i need to set that is not listed in the documentation of rowReorder?

Replies

  • kthorngrenkthorngren Posts: 20,322Questions: 26Answers: 4,774

    The rowReorder docs have this:

    "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!"

    Are you using a sequential list as described?

    Kevin

  • vismarkvismark Posts: 79Questions: 5Answers: 0
    edited October 2017

    Hi Kevin,
    documentation says that the default value for that option is 0 (that means it will search for the index in the very first column of the DataTable).
    So no: i did not specify that option but it shouldn't matter as my first column (index 0 for DataTable) contains the autoinc indexes.

    And in fact, it is working perfectly if i comment out the options which I was talking about in the first message.

    Please refer to this fiddle to understand better the situation: first try to order the rows leaving "ordering: false" and then try to comment it out.

  • kthorngrenkthorngren Posts: 20,322Questions: 26Answers: 4,774

    I guess I'm confused about the problem. Whether ordering is on or off the result is the same. Its just displayed in a different order. Here is what I see:

    ordering: false - original order:

    1 | Row 1
    2 | Row 2
    3 | Row 3
    

    When I move row 2 above 1 this is what I see:

    2 | Row 1
    1 | Row 2
    3 | Row 3
    

    Commenting ordering: false
    //ordering: false - original order:

    1 | Row 1
    2 | Row 2
    3 | Row 3
    

    When I move row 2 above 1 this is what I see:

    1 | Row 2
    2 | Row 1
    3 | Row 3
    

    Same result just different order based on table ordering. What are you expecting or wanting to happen?

    Kevin

  • vismarkvismark Posts: 79Questions: 5Answers: 0
    edited October 2017

    I'm expecting the last result you posted.

    I don't want the table to be orderable with the click over the header of the table, so i put "ordering: false", but this is leading to your first result, which is not what i need.

  • kthorngrenkthorngren Posts: 20,322Questions: 26Answers: 4,774

    I see the issue now. Take a look at this post regarding ordering: false and rowReorder:
    https://datatables.net/forums/discussion/34453

    You would use columns.orderable to turn off the users ability to order the table but have ordering enabled. For example:

      "columnDefs": [
        { "orderable": false, "targets": 0 }
      ],
    

    Kevin

  • vismarkvismark Posts: 79Questions: 5Answers: 0

    I see. Hoped there was a smarter way of doing it. This way I have to disable order manually for each column.

    Thanks for your help anyway! :)

  • kthorngrenkthorngren Posts: 20,322Questions: 26Answers: 4,774

    You could use "targets": "_all" for all columns as described in -options columnDefs.targets.

    Kevin

  • vismarkvismark Posts: 79Questions: 5Answers: 0

    But that way the column containing the autoinc index will be disabled too and we'll be at the starting point...or not?

  • kthorngrenkthorngren Posts: 20,322Questions: 26Answers: 4,774

    Did you try it :smile:

    I think the docs for ordering is a bit confusing. If you set ordering: false you will not see the up arrow indicating that column 0 is sorted. In the doc it says:
    "This parameter is a global option - when disabled, there are no sorting actions applied by DataTables at all."

    columns.orderable only affects the user's ability to change the table order but doesn't disable Datatables ability to order the table. In the doc it says this:
    "Note that this option only effects the end user's ability to order a column. Developers are still able to order a column using the order option or the order() method if required."

    Kevin

  • vismarkvismark Posts: 79Questions: 5Answers: 0

    Again Kevin: thanks :)

  • therultherul Posts: 6Questions: 1Answers: 0

    Thank you,
    I ran into the same problem!

This discussion has been closed.