Flet框架下DataTable排序功能失效且无排序指示器显示的问题求助
Flet框架下DataTable排序功能失效且无排序指示器显示的问题求助
各位好,我现在在Flet里尝试实现一个可排序的DataTable,但遇到了麻烦——表格既不会按照设置的规则排序,连表头的排序指示器也完全没显示出来,实在搞不懂哪里出问题了。
我写的代码如下:
import flet as ft import random class Empleado: def __init__(self): nombres = ["nombre1", "nombre2", "nombre3", "nombre4", "nombre5", "nombre6", "nombre7"] apellidos = ["apellido1", "apellido2", "apellido3", "apellido4", "apellido5", "apellido6", "apellido7"] self.numero_legajo = random.randint(1,50) self.nombre = random.choice(nombres) self.apellido = random.choice(apellidos) self.cuil = random.randint(100000000000, 999999999999) def main(page: ft.Page): lista_empleados = [Empleado() for i in range(5)] page.add( ft.DataTable( columns=[ ft.DataColumn(ft.Text("Legajo")), ft.DataColumn(ft.Text("Nombre y Apellido")), ft.DataColumn(ft.Text("C.U.I.L.")) ], rows=[ ( ft.DataRow( cells=[ ft.DataCell(ft.Text(value=empleado.numero_legajo)), ft.DataCell(ft.Text(value=f"{empleado.nombre} {empleado.apellido}")), ft.DataCell(ft.Text(value=empleado.cuil)), ], data=empleado ) ) for empleado in lista_empleados ], sort_column_index=0, sort_ascending=False, ) ) ft.app(main)
有没有大佬能帮我看看问题出在哪呀?
备注:内容来源于stack exchange,提问作者Ricman1029
相关产品推荐
相关产品推荐

