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

170
Visualizações
Cells loosing added classes after sorting in Vanilla DataTables

I am using vanilla datatables (https://github.com/fiduswriter/Simple-DataTables) and have an issue when ordering the rows. When i click the order header all my custom classes in td/tr are removed.

I init the table using this code

datatable = new DataTable("#orders-table",{
                    perPage:1000,
                    perPageSelect:[5,25,100,1000],
                });

After a button is clicked, I manipulate all "empty" td and add a class on them

let noOrder = document.getElementsByTagName('td');
        for(let i=0;i<noOrder.length;i++){
            //if value = -1 then add the class
            if(noOrder[i].innerHTML == '-1'){

                noOrder[i].classList.add('no-order');
            }
        }

Everything works fine until here.

After I click any sorting heading, the no-order class is automatically removed for some reason.

I am not sure what I am doing wrong. Is there a way to "save" the state of the datatable after the class addition so that the order works without removing my classes?

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