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

329
Visualizações
get max value from datatables

I would like to ask for ideas on how to get the max number from a specific column and return an icon on a different column. I'm using rowCallback, so if there is a maximum number the status will change to active(check mark) and the rest will be x mark.

Here's my desired output: enter image description here

Here's my code:

"rowCallback": function(row, data, num ) {
      
        if(parseInt(data["num"]) === max ){
            $('td:eq(3)', row).html('<a class="btn btn-link btn-success btn-just-icon btn-round"><i class="material-icons">check</i>');
        }
        else{
            $('td:eq(3)',row).html('<a class="btn btn-link btn-danger btn-just-icon btn-round"><i class="material-icons">highlight_off</i>');
            
        }
    },
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

  1. Ideally (if you have access to the data before the HTML is generated) you would compute the maximum value of that column once and pass it to the script.

  2. If you can't do that and need to stay in JS, then the DataTables API has a .column-method that you can use to extract the data. So you can do something like this:

var table = $('#example').DataTable();  // adjust a neccessary to get your table
 
    var max = table
        .column( 2 )
        .data()
        .reduce( function (a,b) {
            return Math.max(a,b);
        } );

about 4 years ago · Juan Pablo Isaza Relatório
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