When i add scrollX i get an error message but without scrollX it works as expected.

When i add scrollX i get an error message but without scrollX it works as expected.

plshelpplshelp Posts: 1Questions: 1Answers: 0

$(table).DataTable({
scrollX:true
});

Error message i recieve:

Cannot read properties of undefined (reading 'style')
at w.fn.init.Ja (jquery.dataTables.min.js:formatted:1467:18)

i traced down the error in jquery.datatables.js and it is on line 5441: divHeaderTable[0].style.width = _fnStringToCss( iOuterWidth );

looks like divHeaderTable[0] is undefined.

For context i am developing in LWC in salesforce

Answers

  • kthorngrenkthorngren Posts: 21,341Questions: 26Answers: 4,954

    Without seeing the problem its hard to say. Many times this is the result of the HTl table not meeting Datatables HTML requirements. If this doesn't help then please post a link to your page or a test case replicating the error. You might also find threads on the forum with the same error that might help you debug. For example this thread and this.

    Kevin

  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin

    Seems to work here: http://live.datatables.net/yoruzaso/1/edit . If you can link to an example showing the error I can dig into it more.

    Allan

  • RupertBarrowRupertBarrow Posts: 23Questions: 3Answers: 0

    Hi @plshelp ,
    Did you get your error fixed ?
    I'm starting to use Datatables.net on Salesforce LWC also : have you any advice or experience to share ?

    Thanks,
    Rupert

  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin

    Hi Rupert,

    If you can link to a page showing the issue, I can look into it.

    Allan

Sign In or Register to comment.