Sorting of Search Panes

Sorting of Search Panes

hkuestershkuesters Posts: 9Questions: 4Answers: 0

Hi!

Is there any possibility, to sort my SearchSelect-List ?

My Site: https://p582810.webspaceconfig.de/suche-dynamic
Use the standard-values, to look the datatable

I have in my datatable a column with age-classes (AKL), they are called e.g. "U07-1" for People af age 6, or "U19-2" for people of age 17. These names are part of the nomenclature of the customer. Now this list is sorted alphabetical, but i want to sort this list by myself.
Is there any possibility?

Thanks for your answer - and excuse my english!
Hubert

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    That's good English, far better than my German!

    To do this, you would use orthogonal data - this example here demonstrates that. You'll see the "Rarity" column is a string, but a number is returned within columns.render to ensure they're ordered appropriately.

    Colin

  • hkuestershkuesters Posts: 9Questions: 4Answers: 0

    Hi Colin!
    Thanks for your post!
    I've understand the idea behind, but it doesn't work. I have made an example with 100 datasets: Example-Link As you can see, is works not correctly. The column "AKL" does not sort the datasets in the given order.
    Or have I done anything wrong?
    Bye
    Hubert

  • kthorngrenkthorngren Posts: 21,261Questions: 26Answers: 4,934
    edited January 2022

    Its hard to visualize the problem so I copied your switch block to show the orthogonal data generated for the display type. Sort the AKL column and you will see the last 3 rows are:

    O45 19
    U07-2 2
    U09-1 3
    

    The Datatables type detection has set the column type to string. When sorting string 2 does come after 19. You need to have columns.render set the type to the data type you are returning or the sort operation. Change if (type === 'sort') { to if (type === 'sort' || type === 'type') {. Toggle the comment of these 2 statements in the example to see that sorting is now working.

    http://live.datatables.net/memikati/1/edit

    Kevin

  • hkuestershkuesters Posts: 9Questions: 4Answers: 0

    Hi Kevin!
    Thank you very much! Now it works! :D
    That was the last step to the right solution!
    Have a nice day - greetings from Brazil
    Hubert

Sign In or Register to comment.