rhandsontable,在列的单元格中换行文本(和自动行高)

rhandsontable,在列的单元格中换行文本(和自动行高),r,shiny,rhandsontable,R,Shiny,Rhandsontable,数据 更好的是,我是否可以保留行高“auto”/default,并根据需要使用文本换行进行扩展 rhandsontable(DF, stretchH = "all", height = 300 ) %>% hot_cols(colWidths = c(100, 50, 50), manualColumnMove = FALSE, manualColumnResize = TRUE ##, wordWrap = "yes

数据

更好的是,我是否可以保留行高“auto”/default,并根据需要使用文本换行进行扩展

rhandsontable(DF, stretchH = "all", height = 300 ) %>%
  hot_cols(colWidths = c(100, 50, 50),
           manualColumnMove = FALSE,
           manualColumnResize = TRUE
           ##, wordWrap = "yes please"
           ) %>%
  hot_rows(rowHeights = 75 ) %>%
  hot_context_menu(allowRowEdit = TRUE, allowColEdit = FALSE)

请帮助并感谢

,因为您将问题标记为
闪亮
,我假设您正在将表格嵌入闪亮的应用程序中。在这种情况下,您可以将表嵌套在
div
中,并使用
css
设置表的样式以使用换行符

以下是一个例子:

rhandsontable(DF, stretchH = "all", height = 300 ) %>%
  hot_cols(colWidths = c(100, 50, 50),
           manualColumnMove = FALSE,
           manualColumnResize = TRUE
           ##, wordWrap = "yes please"
  ) %>%
  hot_rows(rowHeights = NULL ) %>% #default
  hot_context_menu(allowRowEdit = TRUE, allowColEdit = FALSE)

DF默认情况下相关参数
wordWrap
似乎为true:,但在R中未使用。因此,我将在Github上提交一个问题:.perfect-在我的custom.css中定义它。谢谢
rhandsontable(DF, stretchH = "all", height = 300 ) %>%
  hot_cols(colWidths = c(100, 50, 50),
           manualColumnMove = FALSE,
           manualColumnResize = TRUE
           ##, wordWrap = "yes please"
  ) %>%
  hot_rows(rowHeights = NULL ) %>% #default
  hot_context_menu(allowRowEdit = TRUE, allowColEdit = FALSE)
DF <- data.frame(
  a = c("hi", rep(NA, 4)),
  b = sapply(1:5, function(x) paste(sample(letters, size=x*5), collapse='')),
  c = LETTERS[1:5],
  stringsAsFactors = FALSE
)

library(shiny)  
ui <- fluidPage(
  tags$style('#myid * { word-wrap: break-word; color: blue }'),  # apply styling to children of myid
  div(id='myid', rHandsontableOutput('tbl'))
)
server <- function(input, output, session) {
  output$tbl <- renderRHandsontable({
    rhandsontable(DF, stretchH = "all", height = 300 ) %>%
      hot_cols(colWidths = c(100, 50, 50),
               manualColumnMove = FALSE,
               manualColumnResize = TRUE
               ##, wordWrap = "yes please"
      ) %>%
      hot_rows(rowHeights = NULL ) %>% #default
      hot_context_menu(allowRowEdit = TRUE, allowColEdit = FALSE)
  })
}
shinyApp(ui, server)