ColumnControl - inserted instead of in

ColumnControl - inserted instead of in

VynskirVynskir Posts: 9Questions: 3Answers: 0

Link to test case:
https://github.com/DataTables/ColumnControl/blame/a334ecc37062fa42250bf8684a9144ebcade0898/js/dataTables.columnControl.ts#L180

Description of problem:
Hello,

When importing ColumnControl in an app, all the table headers have td child elements instead of th, even when the extension is not enabled for a particular table.

Is this behavior expected ? Shouldn't the line linked above be rather:
tr.appendChild(createElement(isHeader ? 'th' : 'td')); ?

Best regards,
Thibault

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 64,743Questions: 1Answers: 10,713 Site admin

    Hi Thibault,

    Thanks for your question. That's intentional - td is a valid tag to use in the thead row and I was generally expecting any rows in the ehader that are dynamically added to not be the header cells (more likely to be used for search boxes, which are not headers - there would likely be a th above them).

    On that assumption I think td is semantically the correct one to use.

    even when the extension is not enabled for a particular table.

    That statement bothers me though. ColumnControl shouldn't be doing anything on a table that it isn't enable for. Can you give me a link to a test case showing the issue so I can take a look into what is happening there please?

    Thanks,
    Allan

  • VynskirVynskir Posts: 9Questions: 3Answers: 0

    Hello Alan,

    Sorry for the delayed answer, I was on Holidays.

    Thank you for your answer.

    Here is two jsfiddles to reproduce what I observe. Two simple examples that use js as data source with boostrap5 for styling.

    Without ColumnControl:
    https://jsfiddle.net/g7pzxhm9/4/

    With ColumnControl (But not activated for the table ! Only imported as an asset):
    https://jsfiddle.net/bhdkaqgp/

    As you can see it replaces the th by td, which breaks the boldness of the original table and also removes the ordering icons.

    Best regards,
    Thibault

  • VynskirVynskir Posts: 9Questions: 3Answers: 0

    Hello Alan,

    Are my test cases sufficient to reproduce the issue ? I would love to use ColumnControl but I am unable to due to this bug.

    Best regards,
    Thibault

  • allanallan Posts: 64,743Questions: 1Answers: 10,713 Site admin

    HI Thibault,

    Apologies, I totally lost track of this thread, and yes I agree, that is most certainly an error. Thank you for providing the test cases!

    Allan

  • allanallan Posts: 64,743Questions: 1Answers: 10,713 Site admin
    Answer ✓

    Fix committed here and it will be in the next release :).

    Regards,
    Allan

  • VynskirVynskir Posts: 9Questions: 3Answers: 0

    Great !

    Thank you very much for this fix :).

    Best,
    Thibault

Sign In or Register to comment.