Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Added `DOMNode.displayed_children` https://github.com/Textualize/textual/pull/6070
- Added `TextArea.UserInsert` message https://github.com/Textualize/textual/pull/6070
- Added `TextArea.hide_suggestion_on_blur` boolean https://github.com/Textualize/textual/pull/6070
- Added `DataTable.get_row_key` https://github.com/Textualize/textual/pull/6081

### Changed

Expand Down
16 changes: 16 additions & 0 deletions src/textual/widgets/_data_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,22 @@ def get_row_index(self, row_key: RowKey | str) -> int:
raise RowDoesNotExist(f"No row exists for row_key={row_key!r}")
return self._row_locations.get(row_key)

def get_row_key(self, row_index: int) -> RowKey:
"""Return the current key for the row identified by row_index.

Args:
row_index: The index of the row.

Returns:
The current key of the specified row index.

Raises:
RowDoesNotExist: If there is no row with the given index.
"""
if not self.is_valid_row_index(row_index):
raise RowDoesNotExist(f"Row index {row_index!r} is not valid.")
return self._row_locations.get_key(row_index)

def get_column(self, column_key: ColumnKey | str) -> Iterable[CellType]:
"""Get the values from the column identified by the given column key.

Expand Down