Page 1 of 1

Split a Table in Two

Posted: Wed Jan 22, 2020 3:14 am
by jmorales
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.

Re: Split a Table in Two

Posted: Wed Jan 22, 2020 10:45 am
by Radu
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

Re: Split a Table in Two

Posted: Thu Jan 23, 2020 3:33 am
by jmorales
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.

Re: Split a Table in Two

Posted: Thu Jan 23, 2020 10:04 am
by Radu
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

Re: Split a Table in Two

Posted: Fri Jan 24, 2020 3:01 am
by jmorales
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.

Re: Split a Table in Two

Posted: Mon Jan 27, 2020 11:58 am
by Radu
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

Re: Split a Table in Two

Posted: Thu Jan 30, 2020 5:41 am
by jmorales
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.

Re: Split a Table in Two

Posted: Fri Jan 31, 2020 11:47 am
by Radu
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

Re: Split a Table in Two

Posted: Mon Feb 03, 2020 9:41 pm
by jmorales
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.

Re: Split a Table in Two

Posted: Tue Feb 04, 2020 11:08 am
by Radu
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