EurekaCommunity/SplitRow

Indexpath of row

tarikstafford opened this issue · 5 comments

Hey there,

Trying to fetch the indexpath of the row to validate an error of the right row. Unsure of how to add another row below it.

Thx

row.indexPath() returns the IndexPath of the row in the form.
You could then use section.insert(at: index + 1) with the section of that row.

@mats-claassen from the split row (rightRow in this case) indexPath is undefined.

onRowValidationChanged{cell, row in
                        let rowIndex = row.indexPath!.row

ie. this crashes.

You are right, as that row is not added to a section itself. If you have a reference to its parent (SplitRow) row then you can use its indexPath.

If not then I would get the SplitRow using form.row(by: tag) and use its indexPath.

@tarikstafford you might want to use the indexPath of the splitRow itself. Make sure to use a named variable in the rows init to use its value in the embedded rows:

SplitRow<TextRow,TextRow>{ splitRow in
splitRow.rowRight = TextRow{
$0.onRowValidationChanged{ cell, row in
//splitRow.indexPath
}
}

hey @marbetschar & @mats-claassen,

Mats solution works perfectly. Cheers.