simple-datatables icon indicating copy to clipboard operation
simple-datatables copied to clipboard

Cells loosing added classes after sorting

Open agaktr opened this issue 3 years ago • 1 comments

Hello there!

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?

agaktr avatar Jan 19 '22 14:01 agaktr

hello any solves jet?

Lvc4 avatar Sep 02 '22 08:09 Lvc4

Hey @Lvc4 @agaktr , yes you need to go through the rowRender and render methods if you want to manipulate any html inside the table.

johanneswilm avatar Jan 10 '23 23:01 johanneswilm