Bug: Table breaks when the number of columns doesn't match the number of items in a row.

Bug: Table breaks when the number of columns doesn't match the number of items in a row.

peytonhanelpeytonhanel Posts: 1Questions: 1Answers: 0

Error messages shown:

Uncaught TypeError: Cannot set property '_DT_CellIndex' of undefined
at La (clientlib-site.min.js:28558)
at R (clientlib-site.min.js:28550)
at HTMLTableRowElement.<anonymous> (clientlib-site.min.js:28551)
at jquery.min.js:142
at Function.map (jquery.min.js:485)
at jQuery.fn.init.map (jquery.min.js:141)
at pa (clientlib-site.min.js:28551)
at e (clientlib-site.min.js:28627)
at HTMLTableElement.<anonymous> (clientlib-site.min.js:28627)
at Function.each (jquery.min.js:371)

Description of problem:

I use datatable to back an html table that can have merged cells (think like an excel spreadsheet). So in the event that there are no merged cells, everything works fine. As soon as I merge two cells together, the datatable initialization throws an exception. It seems that datatable can't handle a mismatch of columns to actual items in each row. I.e. If you have 3 columns and the row below it only has 2 items, or vise versa.

For example:
This works

Tables Are Cool
col 1 is left-aligned $1600
col 2 is centered $12
col 3 is right-aligned $1

But this breaks the table

Tables Are Cool
col 1 is left-aligned $1600
col 2 is centered $12
col 3 is merged row

Answers

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    Not a bug. DT requires the same number of columns in each row.
    Are you setting default content values in your DT columns initialisation?

  • kthorngrenkthorngren Posts: 21,184Questions: 26Answers: 4,925
    edited December 2020

    You can use columns.defaultContent to set a value if its not in the data.

    I'm not sure what you mean by merged row or merged cells. If you are referring colspanit is not supported in the tbody as described in the HTML Reqs doc.

    Kevin

This discussion has been closed.