From df9bbbcabce165f1c551fc3bad05668700d39be3 Mon Sep 17 00:00:00 2001 From: Saska Karsi Date: Thu, 28 Aug 2025 00:07:04 +0300 Subject: [PATCH 1/3] add get_row_key to DataTable --- src/textual/widgets/_data_table.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/textual/widgets/_data_table.py b/src/textual/widgets/_data_table.py index b78ce528a1..0045ece379 100644 --- a/src/textual/widgets/_data_table.py +++ b/src/textual/widgets/_data_table.py @@ -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: + Thhe 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. From 4149a36916406778c512d7a6ecb5039b7753842e Mon Sep 17 00:00:00 2001 From: Saska Karsi Date: Fri, 29 Aug 2025 17:48:07 +0300 Subject: [PATCH 2/3] typo fix --- src/textual/widgets/_data_table.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/textual/widgets/_data_table.py b/src/textual/widgets/_data_table.py index 0045ece379..9c0af42601 100644 --- a/src/textual/widgets/_data_table.py +++ b/src/textual/widgets/_data_table.py @@ -1040,7 +1040,7 @@ def get_row_key(self, row_index: int) -> RowKey: row_index: The index of the row. Returns: - Thhe current key of the specified row index. + The current key of the specified row index. Raises: RowDoesNotExist: If there is no row with the given index. From 3e21a34a2cd408367b3075d7da6a16bc31995dbf Mon Sep 17 00:00:00 2001 From: Saska Karsi Date: Fri, 29 Aug 2025 17:54:18 +0300 Subject: [PATCH 3/3] add CHANGELOG change --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71f24e0c75..5eec759b8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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