如何在Taipy中突出显示选定的表格行?

huangapple go评论109阅读模式
英文:

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

如何在Taipy中突出显示选定的表格行?

英文:

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 = {&quot;Name&quot;:[&quot;A&quot;,&quot;B&quot;,&quot;C&quot;], &quot;Age&quot;:[1,2,3]}

selected = []

page = &quot;&lt;|{data}|table|on_action=on_selection|selected={selected}|&gt;&quot;

    
def on_selection(state, var_name, action, payload):
    idx = payload[&#39;index&#39;]
    state.selected = [int(idx)]
    ...


Gui(page).run()

如何在Taipy中突出显示选定的表格行?

huangapple
  • 本文由 发表于 2023年5月17日 22:01:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/76272966.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定