Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Unable to make a Taipy table editable

I want to view my dataset with a table and have the option to edit it. Here is the code for my table:

<|{data}|table|editable=True|>

Setting the editable parameter to True doesn’t change anything about the table. I am running the latest version of Taipy (taipy 2.1).

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You should simply assign a custom function to the on_edit property of your table to enable specific actions when a cell is edited.

The on_edit function is triggered when a user attempts to edit a cell. In the code below, the only purpose of the function is to update the cell with the new value provided by the user.

from taipy.gui import Gui

df = {"x": [1, 2, 3, 4, 5],
     "y": [2, 4, 1, 6, 3]}

def on_edit(state, var_name, action, payload):
    id = payload["index"]
    col = payload["col"]
    value = payload["value"]

    print(f"Id: {id}, Col: {col}, Value: {value}")
    print("Row\n", state.df.loc[id, :])

    temp = state.df.copy()
    temp.loc[id, col] = value
    state.df = temp

Gui("<|{df}|table|on_edit=on_edit|>").run()

Editable table

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading