gpt4 book ai didi

javascript - R reactable _如何 chop 单元格内容并在悬停时显示?

转载 作者:行者123 更新时间:2023-12-04 08:40:30 24 4
gpt4 key购买 nike

我在表格中有一些长文本,我将其显示为可 react 的。我希望长文本被 chop ,并且仅在悬停在其顶部时出现。到目前为止,我已经设法 chop 单元格中的文本,但我无法使悬停工作。有什么帮助吗?

library(reactable)
library(tidyverse)

reactable(
iris[1:5, ] %>% mutate(Species = 'This text is long and should only show up entirely when hovering'),
columns = list(
Species = colDef(
html = TRUE,
style = "
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
hover: visible")
)
)```

最佳答案

使用tippy的解决方法:

library(shiny)
library(tippy)
library(reactable)
library(tidyverse)

render.reactable.cell.with.tippy <- function(text, tooltip){
div(
style = "text-decoration: underline;
text-decoration-style: dotted;
text-decoration-color: #FF6B00;
cursor: info;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;",
tippy(text = text, tooltip = tooltip)
)
}

data <- iris[1:5,] %>%
mutate(Species = 'This text is long and should only show up entirely when hovering') %>%
select(Species, everything())

reactable(data,
columns = list(
Species = colDef(
html = TRUE,
cell = function(value, index, name) {
render.reactable.cell.with.tippy(text = value, tooltip = value)}
)
))

关于javascript - R reactable _如何 chop 单元格内容并在悬停时显示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64591293/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com