Skip to content
This repository was archived by the owner on Dec 24, 2025. It is now read-only.

Commit 8381b86

Browse files
committed
Merge remote-tracking branch 'origin/v1' into v1
# Conflicts: # examples/datatable2_example/src/main.py # src/flet_datatable2/datatable2.py # src/flutter/flet_datatable2/lib/src/datatable2.dart
2 parents bcb48ec + 3ddb997 commit 8381b86

File tree

3 files changed

+8
-36
lines changed

3 files changed

+8
-36
lines changed

examples/datatable2_example/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "flet-datatable2-example"
33
version = "1.0.0"
44
description = ""
55
readme = "README.md"
6-
requires-python = ">=3.9"
6+
requires-python = ">=3.10"
77
authors = [
88
{ name = "Flet developer", email = "you@example.com" }
99
]

examples/datatable2_example/src/main.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,15 @@ def main(page: ft.Page):
88
page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
99

1010
def select_row(e: ft.ControlEvent):
11+
print("on_select_row")
1112
e.control.selected = not e.control.selected
1213
e.control.update()
1314

1415
def sort_column(e: ft.DataColumnSortEvent):
15-
dt.sort_column_index = e.column_index
16-
dt.sort_ascending = e.ascending
17-
sorted_desserts = sorted(
18-
desserts,
19-
key=lambda d: getattr(d, e.control.label.value.lower()),
20-
reverse=not dt.sort_ascending,
21-
)
22-
dt.rows = get_data_rows(sorted_desserts)
23-
dt.update()
16+
print(f"Sorting column {e.column_index}, ascending={e.ascending}")
17+
18+
def all_selected(e: ft.ControlEvent):
19+
print("All selected")
2420

2521
def get_data_columns():
2622
data_columns = [
@@ -100,10 +96,10 @@ def get_data_rows(desserts):
10096
sort_ascending=True,
10197
bottom_margin=10,
10298
min_width=600,
99+
on_select_all=all_selected,
103100
columns=get_data_columns(),
104101
rows=get_data_rows(desserts),
105102
),
106103
)
107104

108-
109-
ft.app(main)
105+
ft.run(main)

src/flet_datatable2/datatable2.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -144,27 +144,3 @@ class DataTable2(ft.DataTable):
144144
it is recommended to use a translucent color.
145145
"""
146146

147-
def before_update(self):
148-
super().before_update()
149-
assert all(
150-
isinstance(column, DataColumn2) for column in self.columns
151-
), "columns must contain only DataColumn2 instances"
152-
assert all(
153-
isinstance(row, DataRow2) for row in self.rows
154-
), "rows must contain only DataRow2 instances"
155-
visible_columns = list(filter(lambda column: column.visible, self.columns))
156-
visible_rows = list(filter(lambda row: row.visible, self.rows))
157-
assert (
158-
len(visible_columns) > 0
159-
), "columns must contain at minimum one visible DataColumn"
160-
161-
assert all(
162-
len(list(filter(lambda c: c.visible, row.cells))) == len(visible_columns)
163-
for row in visible_rows
164-
), f"each visible DataRow must contain exactly as many visible DataCells as there are visible DataColumns ({len(visible_columns)})"
165-
assert (
166-
self.divider_thickness is None or self.divider_thickness >= 0
167-
), "divider_thickness must be greater than or equal to 0"
168-
assert self.sort_column_index is None or (
169-
0 <= self.sort_column_index < len(visible_columns)
170-
), f"sort_column_index must be greater than or equal to 0 and less than the number of columns ({len(visible_columns)})"

0 commit comments

Comments
 (0)