TX Text Control .NET Server

Table Object

Object|Introduced in 28.0

Description

The Table object represents a table in a document.

Syntax

Table

Examples

The following example demonstrates Table in a practical document-editing workflow. The Table object represents a table in a document.

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.getID(
            function(result) {
                console.log("get id result:", result);
            }
        );
    }, onTxError);
}, onTxError);

Members

Properties

PropertyDescription
cellsThe collection of all table cells the table consists of.
columnsGets a collection of all columns the table consists of.
nestedTablesGets a collection of all tables nested in this table.
rowsGets a collection of all rows the table consists of.

Methods

MethodDescription
getCanMergeCellsChecks whether table cells can be merged. Table cells can only be merged, if more than one cell in this table is selected.
getCanSplitChecks whether this table can be split. A table can only be split if it contains the current input position and no further text is selected.
getCanSplitCellsChecks whether previously merged table cells in this table can be split. Only selected table cells can be split.
getDescriptiveTextGets the table's descriptive text. The descriptive text is used by screen readers to describe the table to users with visual impairments. An empty string is returned if no descriptive text is set.
getIDGets the table's identifier.
getNestedLevelGets the nested level for the specified table. Top level tables have a level of 1.
getOuterMostTableGets a table's outermost table. This is a top-level table with a nested level of 1. The property's value is an object of the prototype Table or null if this table is already a top-level table.
getOuterTableGets table's outer table.
mergeCellsMerges all selected table cells in this table. {@link Table#getCanMergeCells} can be used to determine, if table cells can be merged or not.
selectSelects the complete table.
selectCellsSelects the part of the table defined through two table cells.
setDescriptiveTextSets the table's descriptive text. The descriptive text is used by screen readers to describe the table to users with visual impairments. An empty string or null can be passed to remove the descriptive text.
setIDSets the table's id.
splitSplits a table below or above the current input position. If the table does not contain the current input position it cannot be split. The getCanSplit method can be used to determine if a table can be split or not. If a table is split above the first row a new line is inserted above the table and if a table is split below the last row a new line is inserted below the table. This is useful to insert text above or below a nested table that immediately starts and/or ends at the beginning or the end of the cell in which it is nested.
splitCellsSplits all selected table cells in this table. Only previously merged cells can be split. The getCanSplitCells method can be used to determine, if table cells can be split or not.

Further Reading

  • Setting the Input Position in TX Text Control –
  • How to Clone a Table Row Using TX Text Control .NET for Windows Forms –
  • Removing Empty Tables –