Got error if there are some invisible columns
cungobu opened this issue · 3 comments
I got an issue when some columns in my table are invisible which can be set by
columnDefs: [ { targets: [0, 1], visible: false }]
or
columns: [{ title: 'Customer Name', data: 'Name', visible: false }]
I'm using colResize with saveState = true. It's ok for the first time but since the next time I got the error like this
Uncaught TypeError: Cannot read properties of null (reading 'match')
from the line
column.sWidth.match(/(\d+)/i)
as sWidth was undefined which could be caused by calculating the width of an invisible DOM.
Actually, we can check null / undefined then skip & continue with visible columns because we do not need to resize invisible columns.
Merged and published. Please recheck with v1.7.1 and close the issue if resolved.
Looks like the PR #11 fixed the original error message! 🎉
-
BEFORE (with 1.7.0): https://codepen.io/hchiam/pen/LYBRMKJ?editors=0010 ➡️ open browser Console, not CodePen's own console ➡️ refresh the page ➡️
Uncaught TypeError: Cannot read properties of null (reading 'match')
error. ❌ 😢 This demo used CDN URL https://cdn.jsdelivr.net/npm/datatables.net-colresize-unofficial@1.7.0/jquery.dataTables.colResize.js -
AFTER (with 1.7.1): https://codepen.io/hchiam/pen/dyjpaQb?editors=0010 ➡️ open browser Console, not CodePen's own console ➡️ refresh the page ➡️ No longer has
Uncaught TypeError: Cannot read properties of null (reading 'match')
error ✅ 😄 - you can do a text search in the Chrome console panel to be sure. This demo used CDN URL https://cdn.jsdelivr.net/npm/datatables.net-colresize-unofficial@1.7.1/jquery.dataTables.colResize.js
But now I see another error message coming from within the _fnShowMaxBoundReached
function. If you still have the console open and refresh the "AFTER" demo, there's now an Uncaught TypeError: Cannot read properties of null (reading 'addClass')
❌ 😢