0
var trs = this.template.querySelectorAll('tr'); 

I am trying to access tr from my table inorder to add classList using,

for(var count=0; count<trs.length; count++){
            trs[count].classList.add("slds-line-height_reset");
        } 

but I cannot see any changes.

5
  • Is the first snippet correct? I think you need to do var trs = this.template.querySelectorAll('tr') where this refers to the module instance.
    – akiradev
    May 4 '20 at 9:55
  • @akiradev I am sorry I tried with the same it was a typo. Still getting the same issue. May 4 '20 at 13:03
  • Is that table generated via a iterator? if so, when does this querySelectorAll code run? you may be looking for the rows before they're rendered.
    – stackasaur
    May 4 '20 at 13:40
  • @stackasaur The code above is written in the renderedCallback() function after null check. The table is created using jQuery datatable. So only after the table is created the code above will run. May 4 '20 at 13:58
  • @yashshah try applying style to the td/th elements in the row instead of the whole row. I'd recommend applying a class to the whole table instead of just the row and using inheritance to style the td/th elements. .myTable td{ }
    – stackasaur
    May 4 '20 at 14:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.