admin管理员组文章数量:1123153
I am trying to make a sorted DataTable in Flet but it doesn't seem to work and I don't know why. My code is the following but it doesn't sort the table and it doesn't display the sort indicator either.
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)
本文标签: pythonsort DataTable in FletStack Overflow
版权声明:本文标题:python - sort DataTable in Flet - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736551939a1944522.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论