Cannot use colspan in tbody

Cannot use colspan in tbody

chaidychaidy Posts: 2Questions: 0Answers: 0

How can we use colsapn in tbody of table

Replies

  • chaidychaidy Posts: 2Questions: 0Answers: 0

    Thank in advance for help...

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75
    edited October 2015

    https://datatables.net/examples/basic_init/complex_header.html

    First thing found on google for "Datatables + colspan" ;-)

  • allanallan Posts: 61,665Questions: 1Answers: 10,096 Site admin

    You can't use colspan or rowspan in DataTables' tbody. It simply isn't supported at this time - sorry.

    Allan

  • that_dirk_guythat_dirk_guy Posts: 2Questions: 0Answers: 0

    I found a hack using invisible cells. See http://stackoverflow.com/a/34012324/1104244

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75
    edited December 2015

    Interesting... i havent seen that before

  • allanallan Posts: 61,665Questions: 1Answers: 10,096 Site admin

    That's cunning - I'm impressed that browsers render that correctly. It should be used with caution though, since it isn't valid HTML - for example run the following through the W3C validator:

    <!doctype html>
    <html>
    <head>
    <title>123</title>
    </head>
    <body>
    <table>
    <tbody>
    <tr>
     <td colspan="3">Wide column</td>
     <td style="display: none;"></td>
     <td style="display: none;"></td>
    </tr>
    <tr>
     <td>Normal column</td>
     <td>Normal column</td>
     <td>Normal column</td>
    </tr>
    </tbody>
    </table>
    </body>
    </html>
    

    Also, I suspect odd things might start happening if you use the column visibility options in DataTables.

    Allan

This discussion has been closed.