I want the user to enter the values and press the plus button to display all the values in the TextField
in the data table and in my code to access these records through a list.
In the picture below, the data table is created again from the beginning, if I want it to be added as a record in the data table every time the value is entered in the TextField and the add option is pressed by the user.
The point is that I want these records to be in the list in the source
def main(page: ft.Page):
def add_clicked(e):
page.add(
ft.DataTable(
columns=[
ft.DataColumn(ft.Text("First name")),
ft.DataColumn(ft.Text("Last name")),
ft.DataColumn(ft.Text("Age")),
],
rows=[
ft.DataRow(
cells=[
ft.DataCell(ft.Text(new_task.value)),
ft.DataCell(ft.Text(new_task1.value)),
ft.DataCell(ft.Text(new_task2.value)),
],
),
]
)
)
# page.add(ft.DataCell(ft.Text(new_task.value)))
# page.add(ft.DataCell(ft.Text(new_task1.value)))
# page.add(ft.DataCell(ft.Text(new_task2.value)))
# page.add(ft.Checkbox(label=new_task.value))
# page.add(ft.Checkbox(label=new_task1.value))
# page.add(ft.Checkbox(label=new_task2.value))
new_task.value = ""
new_task1.value = ""
new_task2.value = ""
page.update()
new_task = ft.TextField(hint_text="Whats needs to be done?")
new_task1 = ft.TextField(hint_text="Whats needs to be done?")
new_task2 = ft.TextField(hint_text="Whats needs to be done?")
page.add(new_task,new_task1,new_task2, ft.FloatingActionButton(icon=ft.icons.ADD, on_click=add_clicked),
)
ft.app(target=main)