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).
>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()
