Hi there,
I’m trying to pass a custom header to the React Handson table and I’m facing some issues.
I created a custom component which is rendered in “afterGetColHeader”.
const renderColumnHeader = (column: number, thElement: HTMLTableHeaderCellElement): void => {
if (column < 0 || column >= columnHelper.length) {
return;
}
const colHeaderElement = thElement.querySelector<HTMLDivElement>('.colHeader');
if (colHeaderElement) {
const parentElement = colHeaderElement.parentElement;
const headerData = columnHelper[column].headerData;
if (parentElement && headerData) {
parentElement.removeChild(colHeaderElement);
const headerContainer = document.createElement('div');
headerContainer.style.height = `${colHeadersHeight}px`;
parentElement.appendChild(headerContainer);
const root = createRoot(headerContainer);
root.render(<AdvancedTableHeader {...headerData} />);
}
}
};
I’m now stuck with the error:
Uncaught TypeError: Cannot read properties of null (reading ‘parentNode’)
at W3.updateCellHeader (index.js:78:151175)
at W3.appendColHeader (index.js:78:150576)
at Array. (index.js:78:141265)
at I0.render (index.js:74:34470)
at W0.render (index.js:78:4242)
at z0.render (index.js:78:5314)
at L2.draw (index.js:78:18530)
at b3.draw (index.js:78:45766)
at S2.refreshAll (index.js:78:79752)
at S2.syncScrollPositions (index.js:78:83451)
at S2.onTableScroll (index.js:78:81641)
at eventManager.addEventListener.passive (index.js:78:80421)
at HTMLDivElement.o10 (index.js:74:5177)
at HTMLDivElement.r (sentry.service.js:5737:16)
and not sure how to procede. Can you help me with this?
Many thanks, Andraz