闪亮-RenderDataTable-显示空白

时间:2020-06-17 14:57:44

标签: r shiny datatable whitespace dt

如何在Shiny App的呈现的DataTable中显示空白?

在下面运行该应用程序时-用户可以双击以编辑单元格,并在数据框“值”中看到前导空格。

我不知道如何使空白可见!

library(shiny)
library(DT)
    ui = fluidPage(dataTableOutput("mytable"))
    server = function(input, output){
      values = data.frame(Demographics = c("Total", "Split_A", "Split_B", "Split_B1", "Split_B2"),check.names = F)

      output$mytable <- renderDT(
        values,
        selection = 'none',
        rownames = FALSE,
        escape   = FALSE,
        editable = T
      )
    }
  shinyApp(ui, server)

1 个答案:

答案 0 :(得分:0)

nirgrahamuk在https://community.rstudio.com/上亲切地回答了

ui = fluidPage(
               tags$style("#mytable { white-space:pre; }"),
                dataTableOutput("mytable")
               )