# Javascript: TableCollection.getItem Method

> Gets the table at the current input position or the first table in the collection with the given id.

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

---

### Description

Gets the table at the current input position or the first table in the collection with the given id.

### Syntax

```javascript
<void> TableCollection.getItem(<RequestTableCallback> callback, [<ErrorCallback> errorCallback], [<number> id])
```

### Parameters

| Parameter | Description |
|---|---|
| callback | Receives the requested table or null if there is no table at the current input position / with the requested id. |
| errorCallback | Optional. Is called when the operation failed with an error. |
| id | Optional. The table's identifier. |

### Examples

The following example demonstrates `TableCollection.getItem` in a practical document-editing workflow. It gets the table at the current input position or the first table in the collection with the given id.

```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 was returned.");
                return;
            }
            
            console.log("get item result:", table);
        },
        onTxError,
        25
    );
}, onTxError);
```

---

## Nearby

- **Previous:** [Javascript: TableCollection.getGridLines Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/tablecollection/getgridlines-method/llms-full.txt)
- **Next:** [Javascript: TableCollection.setGridLines Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/tablecollection/setgridlines-method/llms-full.txt)
