I want to show the selected rows first.

I want to show the selected rows first.

haidy717haidy717 Posts: 1Questions: 1Answers: 0
edited September 2023 in Free community support

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:

Answers

  • kthorngrenkthorngren Posts: 21,449Questions: 26Answers: 4,975
    edited September 2023

    The order of the rows shown is based on the sorting of the table. One option might be to have a hidden column, using columns.visible, and have it as the primary column to sort the table using orderFixed. If the row is selected then set the value of the column to 0 and if not selected set it to 1.

    How this would work is based on how you are selecting the rows now and your data structure. Here is a simple example using the Select extension. It uses the select and deselect events with rows().every() to loop through all the rows that have been selected or deselected. It uses the row().data() API to get and set the row data.
    https://live.datatables.net/dodobuge/27/edit

    The example may need refactoring based on your specific solution.

    Kevin

Sign In or Register to comment.