Datatables throws error when having colspan in column headers
Datatables throws error when having colspan in column headers
![fredlllll](https://secure.gravatar.com/avatar/8cd86496ca968818e129754bcfbfc4bd/?default=https%3A%2F%2Fvanillicon.com%2F8cd86496ca968818e129754bcfbfc4bd_200.png&rating=g&size=120)
using datatables 1.10.25
https://jsfiddle.net/fredlllll/6vxpuLsy/11/ here is a minimum working example.
i have a simple table that has a colspan=2 in the header. When running datatables on it, i get an error in the console "headercells[i] is undefined". this leads to the pagination not being added till i click on one of the headers. furthermore i cant sort by the colspanned column
meanwhile the documentation boasts that datatables is fully compatible with row and colspan https://datatables.net/examples/basic_init/complex_header.html
seems like this simple case slipped through the cracks...
This question has an accepted answers - jump to answer
Answers
just checked multiple versions and this breaks in all of 1.10.x and even in 1.9.x
There is a key sentence in the example you linked:
Your one
thead
with colspan doesn't meet this criteria. Click on the HTML tab of the example to see how that table is setup. You will need a second header row that has ath
for each column for the event listeners.For example:
https://jsfiddle.net/0wepdrhv/
Kevin
so there is no way to make it look like a normal column? cause this 2 level header thing is not what my client wants as design
I would look at using
columns.render
to combine the image with the coin, like this example. Maybe this will get you started:https://jsfiddle.net/uhqn4azd/
You might need to add some styling to center the coin name.
Kevin