英文:
How to highlight a selected row of a table in Taipy?
问题
我正在使用Taipy GUI创建一个Web应用程序。到目前为止,我能够生成一个表格并跟踪所选的行。然而,我想在前端上通过高亮显示来向用户展示他们选择了哪一行。我在文档中找不到如何实现这一点的方法。有人可以帮助我吗?
我查看了文档,但没有找到对我有帮助的内容。
英文:
I am working with Taipy GUI to create a web app. So far I am able to generate a table and keep track of a selected row of the table. However, I want to show the user which row they selected by highlighting it on the frontend. I couldn't find how to do this in the docs. Can someone help me?
I checked the docs but didn't find anything that helped me.
答案1
得分: 2
你可以使用selected属性来获得有关您选择的视觉反馈。
看下面的一个简单示例:
from taipy.gui import Gui
data = {"Name":["A","B","C"], "Age":[1,2,3]}
selected = []
page = "<|{data}|table|on_action=on_selection|selected={selected}|>"
def on_selection(state, var_name, action, payload):
idx = payload['index']
state.selected = [int(idx)]
...
Gui(page).run()
英文:
You can use the selected property to get a visual feedback on your selection.
See below a simple example:
from taipy.gui import Gui
data = {"Name":["A","B","C"], "Age":[1,2,3]}
selected = []
page = "<|{data}|table|on_action=on_selection|selected={selected}|>"
def on_selection(state, var_name, action, payload):
idx = payload['index']
state.selected = [int(idx)]
...
Gui(page).run()
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论