question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request: add support for Handsontables mergeCells option to TableBlock

See original GitHub issue

I set 'mergeCells': True and added 'mergeCells' to contextMenu list in table_options of a wagtail’s TableBlock.

I get functionality of merging cells in context menu of a table in an admin interface while editing a TableBlock widget. It works as expected merging and unmerging cells with content in it.

But all merged cell states got lost when I save a page. It seems that table structure and content converts to list disregarding information of merged cells before sending to a server. You can see this table structure in the browser’s request.

It was never worked before, but Handsontable was upgraded in latest Wagtail version, so I checked it on a latest version (2.6.1), but no luck.

Technical details

Django 2.2 Wagtail 2.6.1 Python 3.6

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:12
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
dianelaccommented, Mar 24, 2021

Hello guys!. Please can we have an update to know if this issue will be fixed any time soon?

1reaction
jandor64commented, Jun 20, 2020

I dug into this a bit, the .getData() call on Handsontable only returns the data in each cell, if it is merged it will return null. That’s not useful, since an empty cell will return null as well.

https://github.com/wagtail/wagtail/blob/c76447246dda344067af502c44388470a0513a91/wagtail/contrib/table_block/static/table_block/js/table.js#L92-L98

I think a new piece of data would need to be added to track the output of hot.getPlugin('mergeCells').mergedCellsCollection.mergedCells

Which will give us something like { col: 1, colspan: 3, removed: false, row: 1, rowspan: 3 }

That, in turn, gets stringified and stored, and then needs to be used when re-initializing this table in the admin, and needs to be worked into the logic for outputting the table template.

I have a JSFiddle demo of retrieving that data on a basic table. https://jsfiddle.net/cx35v1e0/

I don’t know enough about Wagtail to know where to start or how to contribute right now but happy to help if I can.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Merge cells - Guide - Handsontable Documentation
The merging cells feature enables you to combine the contents of two or more cells to create a new larger cell that spans...
Read more >
JavaScript Data Grid Merge cells - Handsontable
Merge adjacent cells, using the "Ctrl + M" shortcut or the context menu. Control merged cells, using Handsontable's API.
Read more >
JavaScript Data Grid MergeCells - Handsontable
Use the MergeCells plugin with its API options and methods to merge adjacent cells, using the "Ctrl + M" shortcut or the context...
Read more >
Tutorial: Merged cells - Handsontable
To enable the merge cells feature, set the mergeCells option to be true or an array. To initialize Handsontable with predefined merged cells,...
Read more >
React Data Grid Merge cells - Handsontable
To enable the merge cells feature, set the mergeCells option to true or to an array. To initialize Handsontable with predefined merged cells, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found