Javascript: Table.mergeCells Method
Description
Merges all selected table cells in this table. {@link Table#getCanMergeCells} can be used to determine, if table cells can be merged or not.
Syntax
<void> Table.mergeCells([<RequestBooleanCallback> callback], [<ErrorCallback> errorCallback])Parameters
| Parameter | Description |
|---|---|
| callback | Optional. Receives whether the merge was succesful. |
| errorCallback | Optional. Is called when the operation failed with an error. |
Examples
The following example demonstrates Table.mergeCells in a practical document-editing workflow. It merges all selected table cells in this table. {@link Table#getCanMergeCells} can be used to determine, if table cells can be merged or not.
function onTxError(error) {
console.error("TX Text Control error:", error.msg);
error.handled = true;
}
TXTextControl.textParts.getMainText(function(mainText) {
const tables = mainText.tables;
tables.getItem(function(table) {
if (!table) {
console.warn("No table is available at the current input position.");
return;
}
table.mergeCells(
function(result) {
if (result) {
console.log("merge cells is available.");
} else {
console.warn("merge cells is not available in the current document state.");
}
},
onTxError
);
}, onTxError);
}, onTxError);