No longer able to include our own colgroup tag in 2.0.0?

No longer able to include our own colgroup tag in 2.0.0?

StevoStevo Posts: 2Questions: 1Answers: 0
edited February 27 in Free community support

I've just upgraded from 1.10 to 2.0.0 - the basic CDN installation - and after some minor adjustments, all is working great. The only issue I've found is that, previously, I was manually including a <colgroup> tag with some class names on the <col> elements (for styling purposes), like this...

 <table id="myTable" class="display">
    <colgroup>
       <col class="col_name" />
       <col class="col_address" />
       <col class="col_number" />
    </colgroup>
    <thead>
       <tr>

however since 2.0.0, DataTables seems to be automatically generating its own <colgroup> tag and placing this immediately before mine (and moving both after the </thead>, although that bit may be irrelevant), so I end up with this:

 </thead>
 <colgroup>
    <col style="width: 103.083px;">
    <col style="width: 91px;">
    <col style="width: 76.3333px;">
 </colgroup>
 <colgroup>
    <col class="col_name" />
    <col class="col_address" />
    <col class="col_number" />
 </colgroup>
 <tbody>

The result is that my <colgroup> is now ignored, together with its CSS classes. (I was using CSS to add a darker vertical border to the 'major' columns - ie. where a colspan is used in the header, then the final column of that colspan would have a darker border on the right.)

Am I right in thinking that something has changed in v2 with respect to <colgroup>, and that I'll need to use JS to add these classes (or nth-of-type selectors) now? Thanks.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,759Questions: 1Answers: 10,111 Site admin
    Answer ✓

    Hi,

    Yes, I'm afraid that is correct. DataTables will now inject its own colgroup which is used for sizing. Sorry, but it was the best way to get the sizing to work and merging an existing tag was proving to be quite complex.

    Use columns.className to assign a column a class.

    Allan

  • StevoStevo Posts: 2Questions: 1Answers: 0

    That's great allan! I didn't realise columns.className existed. Looks like that will achieve what I need. Many thanks.

Sign In or Register to comment.