Skip to content

Commit

Permalink
removed unecessary code from example
Browse files Browse the repository at this point in the history
- the sort by clicked column function was bloat in my opinion
  • Loading branch information
joshbduncan committed Aug 30, 2023
1 parent 7cd0494 commit 312f9ac
Showing 1 changed file with 0 additions and 13 deletions.
13 changes: 0 additions & 13 deletions docs/examples/widgets/data_table_sort.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from rich.text import Text

from textual.app import App, ComposeResult
from textual.events import Click
from textual.widgets import DataTable, Footer

ROWS = [
Expand Down Expand Up @@ -81,18 +80,6 @@ def action_sort_by_country(self) -> None:
reverse=self.sort_reverse("country"),
)

def on_data_table_header_selected(self, event: Click) -> None:
"""Sort `DataTable` items by the clicked column header."""

def sort_by_plain_text(cell):
return cell.plain if isinstance(cell, Text) else cell

column_key = event.column_key
table = self.query_one(DataTable)
table.sort(
column_key, key=sort_by_plain_text, reverse=self.sort_reverse(column_key)
)


app = TableApp()
if __name__ == "__main__":
Expand Down

0 comments on commit 312f9ac

Please sign in to comment.