Trying to add basic Column Filtering but getting TypeError properties of null reading 'textContent'

Trying to add basic Column Filtering but getting TypeError properties of null reading 'textContent'

DougAtHome66DougAtHome66 Posts: 2Questions: 1Answers: 0

Link to test case: https://jsfiddle.net/DougAtHome66/38v6bgh7/12/
Debugger code (debug.datatables.net):
Error messages shown: TypeError: Cannot read properties of null (reading 'textContent')
Description of problem:
I have a basic simple table I am trying to add column filtering but its not working. I am using the example on the DataTables.net web site here: https://datatables.net/extensions/fixedheader/examples/integration/columnFiltering.html

In my real development I'm holding all of the jQuery and DataTables files locally but in my JSFiddle I'm using the online links and both behave the same with the same error.

When using everything in the example I do not get any filters and browser F12 tools reports error:

TypeError: Cannot read properties of null (reading 'textContent')

I am relatively new to jQuery Datatables so am starting by copying the examples provided but its not working.

Ultimately I want to have a drop-down filter at the top of the table on most columns but I am starting with the basics.

I've created an example on JSFiddle as linked above so any help appreciated.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 64,756Questions: 1Answers: 10,716 Site admin
    Answer ✓

    You don't have a footer in the table - hence the result from trying to access a footer cell is null, which is what the error is saying.

    You need to add a footer if you want that or have DataTables create one using columns.footer.

    I'd actually suggest you use ColumnControl if you want to add column filtering to the table.

    Allan

  • DougAtHome66DougAtHome66 Posts: 2Questions: 1Answers: 0

    Thanks Allan,

    Adding the tfoot and cells fixed the error as you indicated. I will look at ColumnControl as I would like to create the filters as drop-down selection lists.

    Much appreciated.

Sign In or Register to comment.