@@ -8,17 +8,13 @@ def main(page: ft.Page):
88 page .vertical_alignment = ft .MainAxisAlignment .CENTER
99 page .horizontal_alignment = ft .CrossAxisAlignment .CENTER
1010
11- def select_row (e : ft .ControlEvent ):
12- print ("on_select_row" )
11+ def handle_row_selection_change (e : ft .Event [ftd .DataRow2 ]):
1312 e .control .selected = not e .control .selected
1413 e .control .update ()
1514
1615 def sort_column (e : ft .DataColumnSortEvent ):
1716 print (f"Sorting column { e .column_index } , ascending={ e .ascending } " )
1817
19- def all_selected (e : ft .ControlEvent ):
20- print ("All selected" )
21-
2218 def get_data_columns ():
2319 data_columns = [
2420 ftd .DataColumn2 (
@@ -72,7 +68,7 @@ def get_data_rows(desserts):
7268 data_rows .append (
7369 ftd .DataRow2 (
7470 specific_row_height = 50 ,
75- on_select_change = select_row ,
71+ on_select_change = handle_row_selection_change ,
7672 cells = [
7773 ft .DataCell (content = ft .Text (dessert .name )),
7874 ft .DataCell (content = ft .Text (dessert .calories )),
@@ -88,7 +84,7 @@ def get_data_rows(desserts):
8884 return data_rows
8985
9086 page .add (
91- dt := ftd .DataTable2 (
87+ ftd .DataTable2 (
9288 show_checkbox_column = True ,
9389 expand = True ,
9490 column_spacing = 0 ,
@@ -97,7 +93,7 @@ def get_data_rows(desserts):
9793 sort_ascending = True ,
9894 bottom_margin = 10 ,
9995 min_width = 600 ,
100- on_select_all = all_selected ,
96+ on_select_all = lambda e : print ( "All selected" ) ,
10197 columns = get_data_columns (),
10298 rows = get_data_rows (desserts ),
10399 ),
0 commit comments