move

fun DocumentEditor.move(fieldId: String, rowId: String, toIndex: Int, schemaId: String? = null)

Moves a table row to a new position within the table.

This function reorders rows within a table by moving a specific row to a new index position. The function calculates the number of positions to move and uses the appropriate move operation (up or down) to achieve the desired position.

Usage Examples:

// Move a row from position 2 to position 0 (beginning of table)
editor.move(
fieldId = "employees_table",
rowId = "row_123",
toIndex = 0
)

// Move a row from position 0 to position 3 (end of table)
editor.move(
fieldId = "employees_table",
rowId = "row_456",
toIndex = 3
)

Parameters

fieldId

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

rowId

The unique identifier of the row to move. The row must exist in the table.

toIndex

The target index position where the row should be moved. If the index is greater than the current number of rows, the row will be moved to the end.

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.

Throws

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

if the rowId doesn't exist in the table.

if the toIndex is negative.