TypeError: Cannot read property 'replace' of null

TypeError: Cannot read property 'replace' of null

AnthonyVAnthonyV Posts: 37Questions: 7Answers: 0

Link to test case:
- This error was caused by an HTML table that was not wide enough for the data
+ a data array that had two extra columns
+ a request to display those columns via the columns option which included the title only for those extra columns.

Debugger code (debug.datatables.net):
aritos

Error messages shown:
TypeError: Cannot read property 'replace' of null
at _fnSortAria (dataTables.js?v=1.1.0.709:6080)
at jQuery.fn.init.<anonymous> (dataTables.js?v=1.1.0.709:1233)
at dataTables.js?v=1.1.0.709:6658
at Function.map (jquery-3.4.1.min.js?v=1.1.0.709:2)
at _fnCallbackFire (dataTables.js?v=1.1.0.709:6657)
at _fnDraw (dataTables.js?v=1.1.0.709:3520)
at _fnAjaxUpdateDraw (dataTables.js?v=1.1.0.709:4145)
at dataTables.js?v=1.1.0.709:3985
at callback (dataTables.js?v=1.1.0.709:3877)
at Object.success (core.js?v=1.1.0.709:2982)

Description of problem:

The function _fnSortAria(settings) attempts to use the col.sTitle and do a replace before validating that the sTitle is set.

I have fixed this by changing my own code but it might help future users if DataTables.net could handle this better or raise a more appropriate error.

Suggested Fix: Test that the sTitle is not null before attempting replace.

This question has an accepted answers - jump to answer

Answers

  • AnthonyVAnthonyV Posts: 37Questions: 7Answers: 0

    Kudos for creating the debug.datatables.net.....

  • allanallan Posts: 61,452Questions: 1Answers: 10,055 Site admin
    Answer ✓

    Thanks :). And thanks for using it!

    The issue is this in your DataTable column's initialisation:

    "title": null,

    columns.title must be a string. If you don't want the column to have a title, just set it to be an empty string:

    title: '',
    

    Allan

  • AnthonyVAnthonyV Posts: 37Questions: 7Answers: 0

    Thanks that explains it.

This discussion has been closed.