'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?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source