# Javascript: Table.split Method

> Splits 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.

- **Product:** TX Text Control .NET Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 28.0
- **Path:** TX Text Control .NET Server > Reference > JavaScript API > Javascript: Table.split Method
- **706 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/table/split-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/table/split-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/table/split-method/llms-full.txt

---

### Description

Splits 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](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/table/getcansplit-method/llms-full.txt) 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.

### Syntax

```javascript
<void> Table.split(<TableAddPosition> tableAddPosition, [<RequestBooleanCallback> callback], [<ErrorCallback> errorCallback])
```

### Parameters

| Parameter | Description |
|---|---|
| tableAddPosition | Specifies the position where to split the table. |
| callback | Optional. Receives whether the table could be split. |
| errorCallback | Optional. Is called when the operation failed with an error. |

### Examples

The following example demonstrates `Table.split` in a practical document-editing workflow. It splits 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.

```javascript
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.split(
            TXTextControl.TableAddPosition.After,
            function(result) {
                if (result) {
                    console.log("split is available.");
                } else {
                    console.warn("split is not available in the current document state.");
                }
            },
            onTxError
        );
    }, onTxError);
}, onTxError);
```

---

## Nearby

- **Previous:** [Javascript: Table.setID Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/table/setid-method/llms-full.txt)
- **Next:** [Javascript: Table.splitCells Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/table/splitcells-method/llms-full.txt)
