Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

144
Visualizações
how to properly sort a column that shows value as string but based on integer rank in datatable?

I am using datable to sort my table of a column called rank. Now my rank is represented as integer (1-4) in the database. So for example, I have rank 1 that is Bronze, rank 2 that is Silver, rank 3 that is Gold and rank 4 that is Platinum. The highest rank is platinum. So I want it to display on the table that shows the order from highest rank to lowest.

On my script I would write something like below:

$("#report").DataTable({
                "searching": false,
                "pageLength": 25,
                "processing": true,
                "order": [2, 'desc'],
                dom: "lBfrtip"
            });

This would not display in the right order as the datatable is sorting the column based on alphabetically. So my column will output the order like:

Silver
Platinum
Gold
Bronze

I want it to be:

Platinum
Gold
Silver
Bronze

Is it possible to modify this to make it to work (without modifying the server side script)?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda