# Javascript: TableRowCollection.add Method

> Adds a count of rows before or after the first or last selected row.

- **Product:** DS Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 28.0
- **Path:** DS Server > Reference > JavaScript API > Javascript: TableRowCollection.add Method
- **457 words**
- **Web URL:** https://docs.textcontrol.com/ds-server/reference/javascript/tablerowcollection/add-method/
- **LLMs URL:** https://docs.textcontrol.com/ds-server/reference/javascript/tablerowcollection/add-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/ds-server/reference/javascript/tablerowcollection/add-method/llms-full.txt

---

### Description

Adds a count of rows before or after the first or last selected row.

### Syntax

```javascript
<void> TableRowCollection.add(<TableAddPosition> tableAddPosition, <number> count, [<RequestBooleanCallback> callback], [<ErrorCallback> errorCallback])
```

### Parameters

| Parameter | Description |
|---|---|
| tableAddPosition | Specifies where the new rows will be added. |
| count | Specifies the count of rows to be added. |
| callback | Optional. Receives whether the new rows could added. |
| errorCallback | Optional. Is called when the operation failed with an error. |

### Examples

The following example demonstrates `TableRowCollection.add` in a practical document-editing workflow. It adds a count of rows before or after the first or last selected row.

```javascript
function onTxError(error) {
    console.error("TX Text Control error:", error.msg);
    error.handled = true;
}

function add(tableRows) {
    tableRows.add(
        TXTextControl.TableAddPosition.After,
        1,
        function(result) {
            if (result) {
                console.log("add is available.");
            } else {
                console.warn("add is not available in the current document state.");
            }
        },
        onTxError
    );
}
```

---

## Nearby

- **Previous:** [TableRowCollection Object](https://docs.textcontrol.com/ds-server/reference/javascript/tablerowcollection/llms-full.txt)
- **Next:** [Javascript: TableRowCollection.getCanAdd Method](https://docs.textcontrol.com/ds-server/reference/javascript/tablerowcollection/getcanadd-method/llms-full.txt)
