0

我希望制作一个具有可扩展行的表,这些行在切换时可能保持打开状态。

我想将包含大量文本的列作为可扩展的行详细信息。问题是当我在 reactable 中使用“详细信息”来扩展该列时,它太宽以至于它离开屏幕使其难以阅读。有没有办法限制可扩展行的最大宽度,使其仅在列所在的位置扩展?

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

library(htmltools)
library(webshot)
library(htmlwidgets)

iris2 <- cbind(USArrests[1:32,], mtcars, iris[1:32,])

data2 <-  iris2 %>%
  mutate(Species = 'This text is long and should only show up entirely when hovering because it is making the shape of my table ugly
                    and difficult to read when expanded. This text is long and should only show up entirely when hovering because it 
                      is making the shape of my table ugly and difficult to read when expanded.This text is long and should only show
                      up entirely when hovering because it is making the shape of my table ugly and difficult to read when expanded. 
                      This text is long and should only show up entirely when hovering because it is making the shape of my table ugly 
                      and difficult to read when expanded.') 

data <- data2 %>% mutate(Species = word(data2$Species, start =1, end=8, sep = fixed(" ")))

dog2 <- reactable( data,
                   columns = list(
                     Species = colDef(details = function(index) {
                       paste(data2[index, "Species"])
                     })),
                   striped = TRUE,
                   bordered = TRUE)

saveWidget(dog2, "test.html")

任何帮助将非常感激!谢谢!

(我发现这个 Q 和 A 很有帮助,但仍然希望可扩展行而不是必须悬停R 可反应 _ 如何截断单元格内容并在悬停时显示?

4

0 回答 0