append

fun DocumentEditor.append(fieldId: String, targetIndex: Int, cellUpdates: Map<Column, Any?>, rowId: String? = null, schemaId: String? = null, parentPath: String? = null)

Appends a new row to a table at a specified target index.

This function creates a new row and inserts it at the specified index position. If the target index is beyond the current number of rows, the new row will be appended at the end. The function supports both regular table fields and collection table fields.

Usage Examples:

// Insert a new row at index 0 (beginning of table)
editor.append(
fieldId = "employees_table",
targetIndex = 0,
cellUpdates = mapOf(
nameColumn to "John Doe",
ageColumn to 30.0
)
)

// Insert a new row after the first row (index 1)
editor.append(
fieldId = "employees_table",
targetIndex = 1,
cellUpdates = mapOf(
nameColumn to "Jane Smith",
ageColumn to 25.0
),
rowId = "custom_row_id"
)

Parameters

fieldId

The unique identifier of the table field to append to. This can be either a regular table field or a collection table field.

targetIndex

The position where the new row should be inserted. If the index is greater than the current number of rows, the row will be appended at the end.

cellUpdates

A map where keys are Column objects and values are the new cell values. The values can be of any type supported by the column (String, Number, etc.).

rowId

Optional custom identifier for the new row. If not provided, a unique ID will be generated.

schemaId

Optional schema identifier for collection fields. This is required when working with collection table fields to specify which schema to use. For regular table fields, this parameter is ignored.

parentPath

Optional parent path for nested tables in collection fields. This is used to specify the hierarchical structure when working with nested tables.

Throws

if the fieldId doesn't correspond to a valid table field.

if the targetIndex is negative.