How can I order a select box below a column?

How can I order a select box below a column?

[Deleted User][Deleted User] Posts: 0Questions: 6Answers: 0

https://datatables.net/examples/api/multi_filter_select.html

I have a column named duration with different options.
I want to show them in that kind of order:
1-2 months, 3-4 months, 1-2 years

But because of string ordering it shows it in this order:
1-2 months, 1-2 years, 3-4 months

I tried using https://datatables.net/examples/plug-ins/sorting_manual.html but that's only working for the table itself I think and not the select box.

Answers

  • kthorngrenkthorngren Posts: 20,269Questions: 26Answers: 4,765

    This code in the multi filter example:

                    column.data().unique().sort().each( function ( d, j ) {
                        select.append( '<option value="'+d+'">'+d+'</option>' )
                    } );
    

    Is the code sorting the select list. You will need to change this code to sort the list in the order you want. It is not something Datatables will do for you nor will the ordering plugin affect this list. The Javascript code needed is specific to the data you have and the order you want it in.

    Kevin

This discussion has been closed.