Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

177
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!