Split a Table in Two

Are you missing a feature? Request it's implementation here.
jmorales
Posts: 57
Joined: Tue Oct 30, 2018 9:47 pm

Split a Table in Two

Post by jmorales » Wed Jan 22, 2020 3:14 am

It would be really great if you could right-click in a row in a table and choose "Split Table." The table would be split into two tables, with the division occurring before the current row. A lot of authoring tools provide a feature like this. Thanks.

Radu
Posts: 6981
Joined: Fri Jul 09, 2004 5:18 pm

Re: Split a Table in Two

Post by Radu » Wed Jan 22, 2020 10:45 am

Hi,

Thanks for the improvement request, we already have an internal issue to add such an action, I will add your feedback on the issue and try to increase its priority. We'll update this forum thread when the issue is fixed.
In the meantime you can select rows in the table using Shift and arrows, then cut (Ctrl-X) and then paste them some place else.
One more thing, do you expect that when you split the table for the header to be also duplicated in the new table? From what I looked MS Word did not duplicate the header.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

jmorales
Posts: 57
Joined: Tue Oct 30, 2018 9:47 pm

Re: Split a Table in Two

Post by jmorales » Thu Jan 23, 2020 3:33 am

Thanks, Radu. Since you ask, I think it would be nice if the header gets duplicated for the new table. That would save me having to copy and paste the header to the new table.

Radu
Posts: 6981
Joined: Fri Jul 09, 2004 5:18 pm

Re: Split a Table in Two

Post by Radu » Thu Jan 23, 2020 10:04 am

Hi,

I would agree copying the header on the new split table would save some time.
One thing I remembered, at some point I created a custom Author action to split a table:

https://github.com/oxygenxml/javascript ... plit-table

The action uses Javascript code working with Oxygen's API. It assumes the table row name is "row".
But it does not copy the header from one table to another.
If you manage to install the custom action I could try to look into modifying the Javascript code to also copy the header.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

jmorales
Posts: 57
Joined: Tue Oct 30, 2018 9:47 pm

Re: Split a Table in Two

Post by jmorales » Fri Jan 24, 2020 3:01 am

Thanks, Radu. I started following the directions and hit a snag in Step 5 of https://blog.oxygenxml.com/2016/10/cust ... iting.html: "Give a custom name to the extension, for example DITA - Custom and then change its Storage to external, then save it to a path like: path/to/.../custom_frameworks/dita-extension/dita-extension.framework." I keep getting the error "The 'dita_-_extension.framework' file must be saved in a subdirectory of one of the configured frameworks directions from 'Document Type Association/Locations' preferences page." Despite the message, I actually already did add the folder to the Locations as
"C:\Users\myusername\Documents\custom_frameworks\dita-extension"
and also as "${homedir}/Documents/custom_frameworks/dita-extension", and the folder does actually exist. Not sure where I'm going wrong. Thanks for your help.

Radu
Posts: 6981
Joined: Fri Jul 09, 2004 5:18 pm

Re: Split a Table in Two

Post by Radu » Mon Jan 27, 2020 11:58 am

Hi,

In the Oxygen Preferences->Document Type Association / Locations page you need to add a reference to the "custom_frameworks" folder, like this:
C:\Users\myusername\Documents\custom_frameworks\

and not to the framework dita-extension folder.
Then click Apply and extend again the DITA framework.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

jmorales
Posts: 57
Joined: Tue Oct 30, 2018 9:47 pm

Re: Split a Table in Two

Post by jmorales » Thu Jan 30, 2020 5:41 am

Thanks, Radu! I got the split table action installed. One side effect: After I split the table, the following syntax error appears for the new one:
Element with duplicate ID "table_r4f_4k3_sgb" found in the same topic context.

Also, as you mentioned, it would be nice if the action would duplicate the colspec and thead items from the original table.

Thanks for your help, I've never looked at a custom action like this before.

Radu
Posts: 6981
Joined: Fri Jul 09, 2004 5:18 pm

Re: Split a Table in Two

Post by Radu » Fri Jan 31, 2020 11:47 am

Hi,

One of my colleagues just updated the Javascript code of the Author action to also try and copy the topic head to the new table. Also the new table has the @id attribute removed from it so that the duplicate id error should not occur anymore:

https://github.com/oxygenxml/javascript ... itTable.js

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

jmorales
Posts: 57
Joined: Tue Oct 30, 2018 9:47 pm

Re: Split a Table in Two

Post by jmorales » Mon Feb 03, 2020 9:41 pm

Thanks Radu! The new code works very well. The only quirk that I see is for table cells that are vertically merged. If I split a table in a way that bisects a vertically merged cell, then afterwards the topic validation shows the errors "A cell is spanning on more rows than available in its parent element" and "The number of cells in the row (2) is less than the value of the table attribute 'cols' (3)". For my purposes, I can just remember to not split tables through a merged cell. However, if you are thinking of ever making this functionality an official part of Oxygen, you would probably need to do something additional to handle this type of situation, such as one of the following (1) refuse to do the table split because of the merged cell, or (2) automatically split the cell vertically before doing the table split, or (3) display an OK or Cancel box that says "If we split the table, we'll have to split a cell first. Is that OK with you?" These are just suggestions. Thanks for your help.

Radu
Posts: 6981
Joined: Fri Jul 09, 2004 5:18 pm

Re: Split a Table in Two

Post by Radu » Tue Feb 04, 2020 11:08 am

Hi,

Thanks for the feedback, I added it on our internal issue. If we ever deliver such an action as part of Oxygen we'll need indeed to also take such cases into account.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Post Reply