I had a question regarding the On_add function for a table. In the following link there is an example of how to add an empty and editable row in a taipy table. I was wondering if it was possible to add an empty, editable column to a table in taipy.
我有一个关于表的ON_ADD函数的问题。在下面的链接中,有一个如何在taipy表中添加空行和可编辑行的示例。我想知道是否可以在taipy中向表中添加一个空的、可编辑的列。
In the example provided: https://www.taipy.io/tips/using-tables/
在提供的示例中:https://www.taipy.io/tips/using-tables/
It's possible to add an empty editable row...
可以添加空的可编辑行...
更多回答
优秀答案推荐
Indeed, it is possible to add an empty, editable column to a table in Taipy GUI applications. I will be using the same code in the article that you included, and I will add a new food_df_on_add_column function regarding the on_add property of the table. Note that we will also need to set the table's rebuild property to True in order to refresh the columns.
实际上,可以在Taipy图形用户界面应用程序中向表添加一个空的、可编辑的列。我将在文章中使用与您包含的相同的代码,并且我将添加一个新的关于表的On_Add属性的参数Food_df_on_Add_Column函数。请注意,为了刷新这些列,我们还需要将表的“Rebuild”属性设置为“True”。
Here is the code:
以下是代码:
from taipy.gui import Gui
import pandas as pd
food_df = pd.DataFrame({
"Meal": ["Lunch", "Dinner", "Lunch", "Lunch", "Breakfast", "Breakfast", "Lunch", "Dinner"],
"Category": ["Food", "Food", "Drink", "Food", "Food", "Drink", "Dessert", "Dessert"],
"Name": ["Burger", "Pizza", "Soda", "Salad", "Pasta", "Water", "Ice Cream", "Cake"],
"Calories": [300, 400, 150, 200, 500, 0, 400, 500],
})
def food_df_on_add_column(state):
df = state.food_df
# Adding a new column with None values
df['NewColumn'] = None
#Replacing the used df
state.food_df = df
main_md = "<|{food_df}|table|rebuild=True|on_add=food_df_on_add_column|>"
Gui(page=main_md).run(dark_mode=False)
In this situation you need to identify row index number and this row column name.
在这种情况下,您需要标识行索引号和此行列名。
if you can send this 2 argument in controller/function via request then fetch only this row after fetched this row then update specific column value.
如果您可以通过请求在控制器/函数中发送这个2参数,那么在获取此行之后只获取此行,然后更新特定的列值。
UPDATE `users` SET `name` = 'HRM' WHERE `users`.`id` = 4;
[enter image description here][1]
更多回答
我是一名优秀的程序员,十分优秀!