Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Great module.
The ability to merge cells, to create tds' that span multiple columns would be great.
As an example, having an information row at the bottom of a table which spans all columns is a common feature, but currently not possible.
On a 3 column table, you would end up with HTML output like so:
<tr>
<td colspan="3">
<p>Text goes here</p>
</td>
</tr>
Comment | File | Size | Author |
---|
Comments
Comment #1
hockey2112 CreditAttribution: hockey2112 commentedI am also very interested in this feature. Has it been given any consideration?
Comment #2
btopro CreditAttribution: btopro commentedPlease merge into #1251738: Allow ability to set table caption
Comment #3
dobe CreditAttribution: dobe commentedI achieved this quick and dirty by modifieing the theme. I had migrated specifcation tables from a wordpress site using tablepress. So all the fields that you wanted to have a colspan on the next field would have "#colspan#" for the data.
So basically with the code above you would put #colspan# and the cell to the left would merge. I am sure you could do this with rowspans as well but this code doesn't do that currently. I wish I had more time to work on this but I am on a time schedule atm.
Comment #4
runzipel CreditAttribution: runzipel commentedThanks to @dobe, withe the help of @kafae here is a little improvement of the dirtyness above:
tags:
#rowspan# merges cell with above
#colspan# merges cell with left
#remove# for "lost" cells
Comment #5
vitalie CreditAttribution: vitalie commentedThis looks like a custom override to the theme function that can be done in a custom module. I do not think this feature, in the form it is now, will make it into the tablefield module.
Comment #6
dobe CreditAttribution: dobe commentedWhile you are correct about the theme override. What is being shown here is proof of concept on a way to achieve this feature. Which is certainly a lot closer than having no solution for users who are looking to be able to do something theoretically simple. If you don't want to include it that is fine. But the request for the feature still exists.
Comment #7
vitalie CreditAttribution: vitalie commented@dobe I am sorry, that's exactly what I wanted to say. It's great that this proof of concept exists and the issue is still active as you can see. This could be developed further into a helper module that could be included into tablefield. Current editor's UI experience is quite demanding, wouldn't you say?
Comment #8
lolandese CreditAttribution: lolandese at HCL Technologies Limited commentedClosed #2848439: Merge two cells into one on the first row as a duplicate of this one.
Comment #9
lolandese CreditAttribution: lolandese at HCL Technologies Limited commentedComment #10
kunago CreditAttribution: kunago commentedThank you for great work. It is easy to make this work with 7.x-3.x version of this module. Just create an overwrite function in your template.php. I am including an example: https://pastebin.com/MzdkpKB5
Comment #11
kunago CreditAttribution: kunago commentedIf you find the rowspan part memory intensive like I did, there is another way to achieve similar result, by cell borders. Steps would be like following:
Result is similar (although not as nice and clean) and you don't put stress on your CPU while generating complicated or long tables.
Comment #12
cristianalcaraz CreditAttribution: cristianalcaraz commentedHi!
I've made a version for the Drupal 8 2.x branch using the code provided by @runzipel Thanks!
I hope someone finds it useful :)
Comment #13
leymannxI've created an installable D8 patch for a sub-module based on the snippets provided in this thread. TableField Cellspan: https://www.drupal.org/project/tablefield/issues/2985110
I'd like to thank everybody for their contributions which helped to create this patch.
Comment #14
lolandese CreditAttribution: lolandese at HCL Technologies Limited commentedSee #2985110: Colspan/Rowspan sub-module "TableField Cellspan".
The 7.x issue should proceed over there under the status "Patch (to be ported)".
Comment #15
lolandese CreditAttribution: lolandese at HCL Technologies Limited commented