如何解决R reactable _如何在悬停时截断单元格内容并显示?
我在表格中有一些长文本显示为可反应。我希望长文本被截断,并且仅当悬停在其上方时才会显示。到目前为止,我已经设法截断了单元格中的文本,但是我无法使鼠标悬停工作。有帮助吗?
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")
)
)```
解决方法
使用小费的解决方法:
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)}
)
))
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。